Skip to content

Instantly share code, notes, and snippets.

@Paradoxis
Created May 31, 2017 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Paradoxis/733af9516af9022d2d4ca7432ff15a96 to your computer and use it in GitHub Desktop.
Save Paradoxis/733af9516af9022d2d4ca7432ff15a96 to your computer and use it in GitHub Desktop.
URL decode CLI

Agressive URL encode

Python based CLI tool to url-decode strings

Usage:

Firstly make a function in your .bash_profile to call the script

function url-decode()
{
    python ~/<path to script>/url_decode.py $@
}

Now simply call the script from your command line :)

$ url-decode "%66%6f%6f"
foo
$ echo "%66%6f%6f" | url-decode
foo
#!/usr/bin/env python3
from argparse import ArgumentParser
from sys import stdin, stdout
from urllib.parse import unquote as url_decode
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("string", nargs="*")
args = parser.parse_args()
if args.string:
stdout.write(url_decode(" ".join(args.string)))
else:
stdout.write(url_decode(stdin.read()[:-1]))