Go to file
renovate[bot] 19af4c5c47 chore(deps): update dependency golangci/golangci-lint to v1.54.1 2023-08-14 04:28:47 +00:00
.chglog chore: adjust changelog template to link to prs instead of issues (#17) 2021-12-12 13:14:39 +01:00
.github fix worind in readme and adjust repo config 2022-07-21 09:47:56 +02:00
cmd/url-parser fix: fallback to stdin automatically if no url provided by flag (#67) 2023-07-23 10:02:46 +02:00
command feat: add option to read url from stdin (#66) 2023-07-19 20:39:30 +02:00
config fix: fallback to stdin automatically if no url provided by flag (#67) 2023-07-23 10:02:46 +02:00
.drone.yml fix drone-matrix template 2023-02-08 17:04:29 +01:00
.gitignore ci: refactor build tools and ci setup (#24) 2022-04-25 12:56:32 +02:00
.golangci.yml chore(deps): update dependency golangci/golangci-lint to v1.53.2 (#61) 2023-06-05 09:52:33 +02:00
.prettierignore chore: end of the year maintenance 2021-12-21 10:54:56 +01:00
CONTRIBUTING.md fix bare url in contribution file (#57) 2023-05-03 11:50:07 +02:00
LICENSE chore: end of the year maintenance 2021-12-21 10:54:56 +01:00
Makefile chore(deps): update dependency golangci/golangci-lint to v1.54.1 2023-08-14 04:28:47 +00:00
README.md fix: fallback to stdin automatically if no url provided by flag (#67) 2023-07-23 10:02:46 +02:00
go.mod fix(deps): update module github.com/urfave/cli/v2 to v2.25.7 (#63) 2023-07-19 15:56:51 +02:00
go.sum fix(deps): update module github.com/urfave/cli/v2 to v2.25.7 (#63) 2023-07-19 15:56:51 +02:00
renovate.json fix renovate preset config 2021-12-21 09:56:03 +01:00

README.md

url-parser

Build Status Go Report Card Codecov GitHub contributors License: MIT

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

Installation

Prebuild multiarch binaries are availabe for Linux only:

curl -L https://github.com/thegeeklab/url-parser/releases/download/v0.1.0/url-parser-0.1.0-linux-amd64 > /usr/local/bin/url-parser
chmod +x /usr/local/bin/url-parser
url-parser --help

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] [arguments...]

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, h       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

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.