Skip to content

Conversation

@am2rican5
Copy link
Contributor

Summary

  • Add url parse subcommand that parses URLs into their components (scheme, host, port, path, query, fragment, username, password)
  • Query parameters are extracted as key-value pairs
  • Duplicate query parameter keys are grouped into arrays (e.g., ?a=1&a=2{"a": ["1", "2"]})

Usage

ut url parse "https://example.com:8080/path?key=value#section"

Add URL parsing feature that extracts scheme, host, port, path, query,
fragment, username, and password from URLs. Query parameters are also
parsed into key-value pairs.
When a URL has duplicate query parameter keys like `?a=1&a=2&b=3`,
values are now grouped by key:
- Single value: returns string `"b": "3"`
- Multiple values: returns array `"a": ["1", "2"]`
@ksdme ksdme merged commit dad85c3 into ksdme:main Dec 26, 2025
14 checks passed
@am2rican5 am2rican5 deleted the feat/url-parse-tool branch December 26, 2025 06:18
@ksdme
Copy link
Owner

ksdme commented Dec 26, 2025

Thanks @am2rican5 for the contribution. I had made some changes on top for consistency. Most notably, the query params are also pretty printed now. But, I have added a --json flag on the top level so you can get structured data out of the tool.

So, the following should still work :)

[I] ksdme@bunny ~/m/ut (main)> ut --json url parse "https://example.org?a=1" | jq '.query_params.a'
"1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants