From fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:14:29 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- .../client/debugger/src/utils/sources-tree/getURL.js | 17 +++++++++++++---- .../client/debugger/src/utils/sources-tree/utils.js | 14 -------------- 2 files changed, 13 insertions(+), 18 deletions(-) (limited to 'devtools/client/debugger/src/utils/sources-tree') diff --git a/devtools/client/debugger/src/utils/sources-tree/getURL.js b/devtools/client/debugger/src/utils/sources-tree/getURL.js index c01fce5f23..5c9e7db6e5 100644 --- a/devtools/client/debugger/src/utils/sources-tree/getURL.js +++ b/devtools/client/debugger/src/utils/sources-tree/getURL.js @@ -56,6 +56,9 @@ const def = { * This is augmented with custom properties like: * - `group`, which is mostly the host of the source's URL. * This is used to sort sources in the Source tree. + * - `filename` which may not be quite matching the URL. + * When files are loaded from "/", they won't have a real name, + * but instead this will report "(index)". * - `fileExtension`, lowercased file extension of the source * (if any extension is available) * - `path` and `pathname` have some special behavior. @@ -66,8 +69,14 @@ export function getDisplayURL(url, extensionName = null) { return def; } - const { pathname, search, protocol, host } = parse(url); - const filename = getUnicodeUrlPath(getFilenameFromPath(pathname)); + let { pathname, search, protocol, host } = parse(url); + + // Decode encoded characters early so that all other code rely on decoded strings + pathname = getUnicodeUrlPath(pathname); + search = getUnicodeUrlPath(search); + host = getUnicodeHostname(host); + + const filename = getFilenameFromPath(pathname); switch (protocol) { case "javascript:": @@ -121,7 +130,7 @@ export function getDisplayURL(url, extensionName = null) { search, filename, fileExtension: getFileExtension("/"), - group: url, + group: getUnicodeUrlPath(url), }; case "data:": @@ -165,7 +174,7 @@ export function getDisplayURL(url, extensionName = null) { search, filename, fileExtension: getFileExtension(pathname), - group: getUnicodeHostname(host), + group: host, }; } diff --git a/devtools/client/debugger/src/utils/sources-tree/utils.js b/devtools/client/debugger/src/utils/sources-tree/utils.js index 0a2f41752b..45eba2d817 100644 --- a/devtools/client/debugger/src/utils/sources-tree/utils.js +++ b/devtools/client/debugger/src/utils/sources-tree/utils.js @@ -28,17 +28,3 @@ export function getRelativePath(url) { } return ""; } - -/** - * - * @param {String} name: Name (e.g. computed in SourcesTreeItem renderItemName), - * which might include URI search. - * @returns {String} result of `decodedURI(name)`, or name if it `name` is malformed. - */ -export function safeDecodeItemName(name) { - try { - return decodeURI(name); - } catch (e) { - return name; - } -} -- cgit v1.2.3