[WEB-4808] fix: joinUrlPath utility fn #7678

This commit is contained in:
Anmol Singh Bhatia 2025-09-01 13:51:26 +05:30 committed by GitHub
parent ab283c7c78
commit 16d531cc7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -317,7 +317,7 @@ export const joinUrlPath = (...segments: string[]): string => {
if (validSegments.length === 0) return "";
// Process segments to normalize slashes
const processedSegments = validSegments.map((segment) => {
const processedSegments = validSegments.map((segment, index) => {
let processed = segment;
// 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
while (processed.endsWith("/")) {
processed = processed.substring(0, processed.length - 1);
if (index < validSegments.length - 1) {
while (processed.endsWith("/")) {
processed = processed.substring(0, processed.length - 1);
}
}
return processed;