From 2f0da26999840f9c848c8e89ddea443eca7d8e40 Mon Sep 17 00:00:00 2001 From: TheSavageTeddy <51810476+TheSavageTeddy@users.noreply.github.com> Date: Sat, 26 Nov 2022 23:57:52 +0800 Subject: [PATCH] add toggle treating "+" as spaces in URL decode --- src/core/operations/URLDecode.mjs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/operations/URLDecode.mjs b/src/core/operations/URLDecode.mjs index 7d6544ac..6d6c196b 100644 --- a/src/core/operations/URLDecode.mjs +++ b/src/core/operations/URLDecode.mjs @@ -23,7 +23,13 @@ class URLDecode extends Operation { this.infoURL = "https://wikipedia.org/wiki/Percent-encoding"; this.inputType = "string"; this.outputType = "string"; - this.args = []; + this.args = [ + { + "name": "Treat \"+\" as space", + "type": "boolean", + "value": false + }, + ]; this.checks = [ { pattern: ".*(?:%[\\da-f]{2}.*){4}", @@ -39,7 +45,8 @@ class URLDecode extends Operation { * @returns {string} */ run(input, args) { - const data = input.replace(/\+/g, "%20"); + const plusIsSpace = args[0]; + const data = plusIsSpace ? input.replace(/\+/g, "%20") : input; try { return decodeURIComponent(data); } catch (err) {