From 3910926c2666c8dafd193d6dd485cc7527d8ecbf Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 15 Mar 2024 23:48:39 +0100 Subject: [PATCH] fix(joinRelativeURL): handle base with protocol (#222) --- src/utils.ts | 6 +++++- test/join.test.ts | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index fafa927..ffe91e6 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -14,6 +14,7 @@ const PROTOCOL_RELATIVE_REGEX = /^([/\\]\s*){2,}[^/\\]/; const PROTOCOL_SCRIPT_RE = /^[\s\0]*(blob|data|javascript|vbscript):$/i; const TRAILING_SLASH_RE = /\/$|\/\?|\/#/; const JOIN_LEADING_SLASH_RE = /^\.?\//; +const JOIN_SEGMENT_SPLIT_RE = /(? { @@ -42,6 +46,10 @@ describe("joinRelativeURL", () => { { input: ["../a", "../../../b"], out: "../../b" }, { input: ["../a", "../../../../b"], out: "../../../b" }, { input: ["../a/", "../b"], out: "b" }, + { + input: ["https://google.com/", "../foo"], + out: "https://google.com/foo", + }, ]; for (const t of relativeTests) {