feat(server): create unit tests for normalizing server URL, and fix logic based on feedback

This commit is contained in:
perf3ct
2025-06-17 21:32:27 +00:00
parent 0fe89115d1
commit b47180a219
2 changed files with 56 additions and 3 deletions

View File

@@ -394,14 +394,14 @@ export function normalizeUrl(url: string): string {
return url;
}
// Fix double slashes (except in protocol) first
url = url.replace(/([^:]\/)\/+/g, '$1');
// Remove trailing slash, but preserve protocol
if (url.endsWith('/') && !url.match(/^https?:\/\/$/)) {
url = url.slice(0, -1);
}
// Fix double slashes (except in protocol)
url = url.replace(/([^:]\/)\/+/g, '$1');
return url;
}