From 7bb93fb725567f116be3547706c0bc21fa2ac020 Mon Sep 17 00:00:00 2001 From: Nikita Tkalenko Date: Fri, 4 Oct 2024 10:44:13 +0300 Subject: [PATCH] fix(ilc): bring back comments --- ilc/common/UrlProcessor.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ilc/common/UrlProcessor.js b/ilc/common/UrlProcessor.js index 1ddc5ac2..ddbd0ea8 100644 --- a/ilc/common/UrlProcessor.js +++ b/ilc/common/UrlProcessor.js @@ -29,11 +29,13 @@ class UrlProcessor { #processUrlTrailingSlash = (url) => { if (!UrlProcessor.validSchemes.some((scheme) => url.startsWith(scheme))) { + // any combination of slashes at the beginning URL class classifies as an absolute link with http: protocol, so we remove them at the end url = url.replace(/^[\/\\]+/gi, '/'); } const parsedUrl = new URL(url, this.#fakeBaseInCasesWhereUrlIsRelative); + // Ensure there are no double slashes in the pathname, excluding the start parsedUrl.pathname = parsedUrl.pathname.replace(/\/{2,}/g, '/'); const doesUrlPathnameEndWithTrailingSlash = parsedUrl.pathname[parsedUrl.pathname.length - 1] === '/';