From 398a8d1051d954acf9cae0bf3bd405456fedca6d Mon Sep 17 00:00:00 2001 From: Rahul Yedida Date: Wed, 6 Jan 2021 09:13:08 +0000 Subject: [PATCH] Bug 1678298 - [devtools] Use decodeURIComponent instead of decodeURI r=bomsy Depends on D98294 Differential Revision: https://phabricator.services.mozilla.com/D98388 --- devtools/client/shared/unicode-url.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/devtools/client/shared/unicode-url.js b/devtools/client/shared/unicode-url.js index 5f9f70780165..c13e1314c6d2 100644 --- a/devtools/client/shared/unicode-url.js +++ b/devtools/client/shared/unicode-url.js @@ -88,7 +88,13 @@ function getUnicodeUrl(url) { return url; } const readableHostname = getUnicodeHostname(hostname); - url = decodeURI(url); + + /* We use `decodeURIComponent` instead of decodeURI as the + * later does not decode some characters, it only can decode characters + * previously encoded by the encodeURI. See + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI#Description + */ + url = decodeURIComponent(url); return url.replace(hostname, readableHostname); } catch (err) {} return url;