use URI.resolve
This commit is contained in:
parent
ceede791bd
commit
892f89e0e2
1 changed files with 17 additions and 6 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue