Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adrianrudnik/uritool
Command-line tool that helps with URI/URL handling and proper part extraction, escaping and parsing.
https://github.com/adrianrudnik/uritool
bash cmd golang shell snap uri-parser url-parser
Last synced: 29 days ago
JSON representation
Command-line tool that helps with URI/URL handling and proper part extraction, escaping and parsing.
- Host: GitHub
- URL: https://github.com/adrianrudnik/uritool
- Owner: adrianrudnik
- License: mit
- Created: 2019-04-03T11:54:05.000Z (over 5 years ago)
- Default Branch: develop
- Last Pushed: 2020-04-28T16:45:56.000Z (over 4 years ago)
- Last Synced: 2024-06-20T08:01:15.214Z (5 months ago)
- Topics: bash, cmd, golang, shell, snap, uri-parser, url-parser
- Language: Go
- Homepage:
- Size: 133 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# uritool
Command-line tool that helps with URI/URL handling and proper part extraction, escaping and parsing.
[![license](https://img.shields.io/github/license/adrianrudnik/uritool.svg)](https://lab.klonmaschine.de/adrian.rudnik/uritool/blob/develop/LICENSE)
[![pipeline status](https://lab.klonmaschine.de/adrian.rudnik/uritool/badges/develop/pipeline.svg)](https://lab.klonmaschine.de/adrian.rudnik/uritool/commits/develop)
[![coverage report](https://lab.klonmaschine.de/adrian.rudnik/uritool/badges/develop/coverage.svg)](https://lab.klonmaschine.de/adrian.rudnik/uritool/commits/develop)
[![go report card](https://goreportcard.com/badge/github.com/adrianrudnik/uritool)](https://goreportcard.com/report/github.com/adrianrudnik/uritool)## Installation
The following methods are available:
### Download
Directly download a version from the [release page](https://github.com/adrianrudnik/uritool/releases).
### Snap
Install it on any system supporting snaps:
```sh
snap install uritool
```### Build yourself
Download the source code, review it and build it:
```sh
go test ./...
go build -mod=vendor .
```This should build a local binary for your system with the name `uritool` in your current working directory.
## Usage
### Query commands
Encodes the given value to a valid query parameter value:
```sh
uritool query escape --no-newline "hello / world!%%"# > hello+%2F+world%25%25
```Decodes the given escaped query value:
```sh
uritool query unescape "hello+%2F+world%25%25"# > hello / world!%%
```### Path commands
Escape the given value to a valid escaped path value:
```sh
uritool path escape "hello world"# > hello%20world
```Unescape the given escaped path value:
```sh
uritool path unescape "hello%20world"# > hello world
```### Parse commands
Parse a given URI and return all information as JSON:
```sh
uritool parse uri "https://my:[email protected]:8080/what/ ever?this=is&this=isnot#doing"# > {
# > "Scheme": "https",
# > "Opaque": "",
# > "Username": "my",
# > "Password": "pass",
# > "PasswordIsGiven": true,
# > "Host": "the.example.com:8080",
# > "Hostname": "the.example.com",
# > "Port": 8080,
# > "Path": "/what/ ever",
# > "PathEscaped": "/what/%20ever",
# > "RawQuery": "this=is\u0026this=isnot",
# > "Fragment": "doing",
# > "Query": {
# > "this": [
# > "is",
# > "isnot"
# > ]
# > }
# > }
```But sometimes you just want a specific part or combination of it, so use can use the [go template](https://golang.org/pkg/text/template/) language:
```sh
uritool parse uri --format="Welcome {{.Username}} from {{.Hostname}}" "https://adrian:[email protected]:8080/?uh=oh"# > Welcome adrian from the.example.com
uritool parse uri --format="Second entry is {{index .Query.things 1}}" "https://adrian:[email protected]:8080/?things=one&things=two"
# > Second entry is two
```You can also parse query strings (leading "?" will be removed):
```sh
uritool parse query "?this=is&this=isnot"# > {
# > "this": [
# > "is",
# > "isnot"
# > ]
# > }
```This is also workable with the [go template](https://golang.org/pkg/text/template/) language:
```sh
uritool parse query -n --format="{{index .search 0}}" "search=mister&filter=x"# > mister
```