From 892f89e0e23f9ef1cac2eef40d82c25ba8abc153 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 3 Mar 2025 16:08:15 -0800 Subject: [PATCH 1/2] use URI.resolve --- core/util/uri.ts | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/core/util/uri.ts b/core/util/uri.ts index 13d7956ac..a5a84d3b4 100644 --- a/core/util/uri.ts +++ b/core/util/uri.ts @@ -116,19 +116,30 @@ export function getLastNUriRelativePathParts( } export function joinPathsToUri(uri: string, ...pathSegments: string[]) { - const components = URI.parse(uri); + let baseUri = uri; + if (baseUri.at(-1) !== "/") { + baseUri += "/"; + } const segments = pathSegments.map((segment) => pathToUriPathSegment(segment)); - components.path = `${components.path}/${segments.join("/")}`; - return URI.serialize(components); + return URI.resolve(baseUri, segments.join("/")); } +// const components = URI.parse(uri); +// return URI.serialize(components); +// components.path = `${components.path}/${segments.join("/")}`; + export function joinEncodedUriPathSegmentToUri( uri: string, pathSegment: string, ) { - const components = URI.parse(uri); - components.path = `${components.path}/${pathSegment}`; - return URI.serialize(components); + let baseUri = uri; + if (baseUri.at(-1) !== "/") { + baseUri += "/"; + } + return URI.resolve(baseUri, pathSegment); + // const components = URI.parse(uri); + // components.path = `${components.path}/${pathSegment}`; + // return URI.serialize(components); } export function getShortestUniqueRelativeUriPaths( From a8d9a312a6efb935edca0de7cd8e77fb6d9a2660 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 3 Mar 2025 16:12:30 -0800 Subject: [PATCH 2/2] cleanup --- core/util/uri.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/core/util/uri.ts b/core/util/uri.ts index a5a84d3b4..e180a0a69 100644 --- a/core/util/uri.ts +++ b/core/util/uri.ts @@ -124,10 +124,6 @@ export function joinPathsToUri(uri: string, ...pathSegments: string[]) { return URI.resolve(baseUri, segments.join("/")); } -// const components = URI.parse(uri); -// return URI.serialize(components); -// components.path = `${components.path}/${segments.join("/")}`; - export function joinEncodedUriPathSegmentToUri( uri: string, pathSegment: string, @@ -137,9 +133,6 @@ export function joinEncodedUriPathSegmentToUri( baseUri += "/"; } return URI.resolve(baseUri, pathSegment); - // const components = URI.parse(uri); - // components.path = `${components.path}/${pathSegment}`; - // return URI.serialize(components); } export function getShortestUniqueRelativeUriPaths(