[WEB-4808] fix: joinUrlPath utility fn #7678
This commit is contained in:
parent
ab283c7c78
commit
16d531cc7a
1 changed files with 5 additions and 3 deletions
|
|
@ -317,7 +317,7 @@ export const joinUrlPath = (...segments: string[]): string => {
|
||||||
if (validSegments.length === 0) return "";
|
if (validSegments.length === 0) return "";
|
||||||
|
|
||||||
// Process segments to normalize slashes
|
// Process segments to normalize slashes
|
||||||
const processedSegments = validSegments.map((segment) => {
|
const processedSegments = validSegments.map((segment, index) => {
|
||||||
let processed = segment;
|
let processed = segment;
|
||||||
|
|
||||||
// Remove leading slashes from all segments except the first
|
// Remove leading slashes from all segments except the first
|
||||||
|
|
@ -326,8 +326,10 @@ export const joinUrlPath = (...segments: string[]): string => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove trailing slashes from all segments except the last
|
// Remove trailing slashes from all segments except the last
|
||||||
while (processed.endsWith("/")) {
|
if (index < validSegments.length - 1) {
|
||||||
processed = processed.substring(0, processed.length - 1);
|
while (processed.endsWith("/")) {
|
||||||
|
processed = processed.substring(0, processed.length - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return processed;
|
return processed;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue