Go to file
2024-11-05 14:35:26 +01:00
.github fix ci 2023-08-22 09:04:28 +02:00
.gitsv use uppercase title for breaking changes in changelog 2023-10-28 22:59:46 +02:00
.woodpecker chore(deps): update golang minor version (#106) 2024-10-03 14:27:04 +02:00
cmd/url-parser feat: add option for json output (#109) 2024-11-05 14:35:26 +01:00
command feat: add option for json output (#109) 2024-11-05 14:35:26 +01:00
config feat: add option for json output (#109) 2024-11-05 14:35:26 +01:00
.dictionary ci: fix releases and add linkcheck (#71) 2023-10-17 00:36:07 +02:00
.gitignore fix gitignore 2023-08-22 22:24:12 +02:00
.golangci.yml ci: fix golangci-lint deprecations 2024-05-12 11:08:22 +02:00
.markdownlint.yml ci: migrate to woodpecker (#69) 2023-08-21 16:06:34 +02:00
.prettierignore ci: migrate to woodpecker (#69) 2023-08-21 16:06:34 +02:00
CONTRIBUTING.md fix bare url in contribution file (#57) 2023-05-03 11:50:07 +02:00
go.mod feat: add option for json output (#109) 2024-11-05 14:35:26 +01:00
go.sum feat: add option for json output (#109) 2024-11-05 14:35:26 +01:00
LICENSE chore: end of the year maintenance 2021-12-21 10:54:56 +01:00
Makefile chore(deps): update golang minor version (#106) 2024-10-03 14:27:04 +02:00
README.md feat: add option for json output (#109) 2024-11-05 14:35:26 +01:00
renovate.json fix renovate preset config 2021-12-21 09:56:03 +01:00

url-parser

Simple command-line URL parser

Build Status Go Report Card GitHub contributors License: MIT

Inspired by herloct/url-parser, a simple command-line utility for parsing URLs.

Installation

Prebuilt multiarch binaries are available for Linux only.

curl -SsfL https://github.com/thegeeklab/url-parser/releases/latest/download/url-parser-linux-amd64 -o /usr/local/bin/url-parser
chmod +x /usr/local/bin/url-parser

Build

Build the binary from source with the following command:

make build

Usage

$ url-parser --help
NAME:
   url-parser - Parse URL and shows the part of it.

USAGE:
   url-parser [global options] command [command options]

VERSION:
   devel

COMMANDS:
   all, a        Get all parts from url
   scheme, s     Get scheme from url
   user, u       Get username from url
   password, pw  Get password from url
   path, pt      Get path from url
   host, ht      Get hostname from url
   port, p       Get port from url
   query, q      Get query from url
   fragment, f   Get fragment from url
   help, h       Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --url value    source url to parse [$URL_PARSER_URL]
   --help, -h     show help
   --version, -v  print the version

Examples

$ url-parser --url https://somedomain.com host
somedomain.com

$ url-parser --url https://herloct@somedomain.com user
herloct

$ url-parser --url https://somedomain.com/path/to path
/path/to

$ url-parser --url https://somedomain.com/path/to path --path-index=1
to

$ url-parser --url https://somedomain.com/?some-key=somevalue query
some-key=somevalue

$ url-parser --url https://somedomain.com/?some-key=somevalue query --query-field=some-key
somevalue

# It is also possible to read the URL from stdin
$ echo "https://somedomain.com" | url-parser host
somedomain.com

# Get json output or all parsed parts
$ url-parser --url https://somedomain.com/?some-key=somevalue all --json
{"scheme":"https","hostname":"somedomain.com","port":"","path":"/","fragment":"","rawQuery":"some-key=somevalue","queryParams":[{"key":"some-key","value":"somevalue"}],"username":"","password":""}

Contributors

Special thanks to all contributors. If you would like to contribute, please see the instructions.

License

This project is licensed under the MIT License - see the LICENSE file for details.