Skip to content

Commit

Permalink
snippets: Add urldecode
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Sep 12, 2021
1 parent 50d00d8 commit 79a1aea
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions dev/snippets.jq
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ def flac_dump:
, (.. | select(._format == "flac_frame"))
] | bits;

def urldecode:
gsub(
"%(?<c>..)";
( .c
| ascii_downcase
| explode
| map(.-48 | if .>=49 then .-39 else . end)
| [.[0]*16+.[1]]
| implode
)
);

def radix62sp: radix(62; "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; {
"0": 0, "1": 1, "2": 2, "3": 3,"4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9,
"a": 10, "b": 11, "c": 12, "d": 13, "e": 14, "f": 15, "g": 16,
Expand Down

0 comments on commit 79a1aea

Please sign in to comment.