From 79a1aea1d0714c901fd6f5ac2bd9c079b8d6f7b1 Mon Sep 17 00:00:00 2001 From: Mattias Wadman Date: Thu, 19 Aug 2021 17:46:43 +0200 Subject: [PATCH] snippets: Add urldecode --- dev/snippets.jq | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dev/snippets.jq b/dev/snippets.jq index ce4a4ab8..fdcf3b9c 100644 --- a/dev/snippets.jq +++ b/dev/snippets.jq @@ -12,6 +12,18 @@ def flac_dump: , (.. | select(._format == "flac_frame")) ] | bits; +def urldecode: + gsub( + "%(?..)"; + ( .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,