diff options
Diffstat (limited to 'op_crates/web/11_url.js')
-rw-r--r-- | op_crates/web/11_url.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/op_crates/web/11_url.js b/op_crates/web/11_url.js index f2d12f5be..d60f9769a 100644 --- a/op_crates/web/11_url.js +++ b/op_crates/web/11_url.js @@ -37,7 +37,16 @@ } function decodeSearchParam(p) { - return decodeURIComponent(p.replace(/\+/g, " ")); + const s = p.replaceAll("+", " "); + const decoder = new TextDecoder(); + + return s.replace(/(%[0-9a-f]{2})+/gi, (matched) => { + const buf = new Uint8Array(Math.ceil(matched.length / 3)); + for (let i = 0, offset = 0; i < matched.length; i += 3, offset += 1) { + buf[offset] = parseInt(matched.slice(i + 1, i + 3), 16); + } + return decoder.decode(buf); + }); } const urls = new WeakMap(); |