Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ko1nksm/url
URL builder with URL encoding for CLI and portable shell scripts
https://github.com/ko1nksm/url
bash curl posix shell urlencode wget
Last synced: about 1 month ago
JSON representation
URL builder with URL encoding for CLI and portable shell scripts
- Host: GitHub
- URL: https://github.com/ko1nksm/url
- Owner: ko1nksm
- License: 0bsd
- Created: 2023-08-21T12:11:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-28T14:56:16.000Z (over 1 year ago)
- Last Synced: 2024-10-12T02:11:25.978Z (3 months ago)
- Topics: bash, curl, posix, shell, urlencode, wget
- Language: Shell
- Homepage:
- Size: 33.2 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# url
URL builder with URL encoding for CLI and portable shell scripts.
It is suitable for building URLs for `curl`, `wget`, etc.## Usage
**The specification is not yet stable.**
```txt
Usage: url [-rs] [-nSN] [--] URLPATH [PARAMETERS]...
Usage: url -p [-j DELIMITER] [-nSN] [--] FORMAT [ARGUMENTS]...
Usage: url -e [-m] [-SN] [--] [ARGUMENTS]...
Usage: url -d [-S] [--] [ARGUMENTS]...URLPATH: url path
PARAMETERS: [ -KEY VALUE | =STRING | #FRAGMENT ]...Global options:
-n Do not print the trailing newline character
-p, --printf printf mode (default: build mode)
-e, --encode URL Encoder mode (accepts stdin)
-d, --decode URL Decoder mode (accepts stdin)Build mode options:
-s Sort keys
-r Remove empty value keyPrintf mode options:
-j, --join DELIMITER Joins strings with the delimiter (default: '\n')Encode mode options:
-m Read multiple linesCharacter conversion Options:
-S Use + instead of %20
-N Normalize newline to \r\n
```## Example
build mode:
```console
$ url "http://example.com/" -param1 あ -param2 "か" "#さ"
http://example.com/?param1=%E3%81%82¶m2=%E3%81%8B#%E3%81%95$ url "http://example.com/" =あいうえお
http://example.com/?%E3%81%82%E3%81%84%E3%81%86%E3%81%88%E3%81%8A
```printf mode:
```console
$ url --printf "http://example.com/?param1=%s¶m2=%s" あ a ア A
http://example.com/?param1=%E3%81%82¶m2=%EF%BD%81
http://example.com/?param1=%E3%82%A2¶m2=%EF%BC%A1
```## Use as a library
License is 0BSD. Feel free to copy and use the functions.
### urlbuild
```txt
urlbuild URLPATH [ARGUMENTS]...
URLPATH: url path
ARGUMENTS: [ -KEY VALUE | =STRING | #FRAGMENT ]...Variables:
SHURL_SPACE: A character to use instead of %20
SHURL_EOL: Characters used on new lines
```### urlencode
```txt
urlencode [ARGUMENTS]...ARGUMENTS: argument to be URL-encoded
Variables:
SHURL_SPACE: A character to use instead of %20
SHURL_EOL: Characters used on new lines
```### urldecode
```txt
urldecode [ARGUMENTS]...ARGUMENTS: argument to be URL-decoded
Variables:
SHURL_SPACE: A character to use instead of %20
SHURL_EOL: Characters used on new lines
```