Crates.io | urlmatic |
lib.rs | urlmatic |
version | 0.5.0 |
source | src |
created_at | 2022-05-19 01:08:42.791462 |
updated_at | 2022-06-10 20:31:42.386834 |
description | Slice and dice URLs on the command line |
homepage | |
repository | https://github.com/bww/urlmatic |
max_upload_size | |
id | 589436 |
size | 21,336 |
Perform some useful manipulation of URLs. This thing doesn't do much yet.
Resolves a relative URL against the provided base URL and prints the result.
$ urlmatic resolve --base 'https://www.example.com/documents/letter.html?length=100' '../index.html?length=200'
> https://www.example.com/index.html?length=200
Removes the specified number of components from the end of a URL's path and prints the result.
$ urlmatic trim --count 2 'https://www.example.com/documents/letter.html?length=100'
> https://www.example.com/?length=100
Replace specific components in a URL and print the result.
$ urlmatic rewrite \
--username admin \
--host another.com \
--path /cgi-bin/q \
--query 'offset=0&length=100' \
--fragment 'anchor-name' \
https://example.com/query
> https://admin@another.com/cgi-bin/q?offset=0&length=100#anchor-name
application/x-www-form-urlencoded
dataURL-encode form data form/query data.
$ urlmatic encode -k yep -v 👍 -k nope -v 👎
> yep=%F0%9F%91%8D&nope=%F0%9F%91%8E
$ urlmatic encode yep=👍 nope=👎
> nope=%F0%9F%91%8E&yep=%F0%9F%91%8D
application/x-www-form-urlencoded
dataURL-decode form data and extract values.
$ urlmatic decode 'yep=%F0%9F%91%8D&nope=%F0%9F%91%8E'
> yep: 👍
> nope: 👎
$ urlmatic decode --select yep 'yep=%F0%9F%91%8D&nope=%F0%9F%91%8E'
> 👍
$ urlmatic decode --select nope,yep 'yep=%F0%9F%91%8D&nope=%F0%9F%91%8E'
> 👍
> 👎
Compose and modify a URL using a few commands.
$ echo 'https://example.com/path/to/query' |
urlmatic rewrite --host another.com --query $(urlmatic encode -k yep -v 👍) |
urlmatic trim --count 2
> https://another.com/path?yep=%F0%9F%91%8D