{"ScriptPreparationCode":"var urlQueryToObj1 = (url) =\u003E {\r\n const idx = url.indexOf(\u0022?\u0022);\r\n if (idx \u003C 0)\r\n return {};\r\n const query = url.slice(idx \u002B 1);\r\n return query.split(\u0022\u0026\u0022).reduce((obj, str) =\u003E {\r\n const idx = str.indexOf(\u0022=\u0022);\r\n const key = idx \u003C 0 ? str : str.slice(0, idx);\r\n const val = idx \u003C 0 ? true : decodeURIComponent(str.slice(idx \u002B 1));\r\n obj[key] = val;\r\n return obj;\r\n }, {});\r\n}\r\nvar urlQueryToObj2 = (url) =\u003E {\r\n const idx = url.indexOf(\u0022?\u0022);\r\n if (idx \u003C 0)\r\n return {};\r\n const query = url.slice(idx \u002B 1);\r\n let output = {};\r\n query.split(\u0022\u0026\u0022).forEach((str) =\u003E {\r\n const idx = str.indexOf(\u0022=\u0022);\r\n const key = idx \u003C 0 ? str : str.slice(0, idx);\r\n const val = idx \u003C 0 ? true : decodeURIComponent(str.slice(idx \u002B 1));\r\n output[key] = val;\r\n });\r\n return output;\r\n}\r\nvar url = \u0022https://example.com/path/to/page?name=ferret\u0026color=purple\u0022;\r\n","TestCases":[{"Name":"urlQueryToObj1","Code":"const val = urlQueryToObj1(url);","IsDeferred":false},{"Name":"urlQueryToObj2","Code":"const val = urlQueryToObj1(url);","IsDeferred":false}]}