From 16d531cc7a63b265a983606fd76a4654afedf683 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Date: Mon, 1 Sep 2025 13:51:26 +0530 Subject: [PATCH] [WEB-4808] fix: joinUrlPath utility fn #7678 --- packages/utils/src/string.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/utils/src/string.ts b/packages/utils/src/string.ts index 062a162ab..dc7c44b02 100644 --- a/packages/utils/src/string.ts +++ b/packages/utils/src/string.ts @@ -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;