diff --git a/servers/fdr/src/util/ParsedBaseUrl.ts b/servers/fdr/src/util/ParsedBaseUrl.ts index bc8e89791e..47f6aa4b3a 100644 --- a/servers/fdr/src/util/ParsedBaseUrl.ts +++ b/servers/fdr/src/util/ParsedBaseUrl.ts @@ -1,5 +1,9 @@ const HAS_HTTPS_REGEX = /^https?:\/\//i; +function checkPathNameContainsMoreThanSpecialChars(pathname: string): boolean { + return !/^.*([a-z0-9]).*$/.test(pathname); +} + export class ParsedBaseUrl { public readonly hostname: string; public readonly path: string | undefined; @@ -31,7 +35,7 @@ export class ParsedBaseUrl { hostname: parsedURL.hostname, // clean up any special-character-only (no alphanumeric) paths path: - !/^.*([a-z0-9]).*$/.test(parsedURL.pathname) || + checkPathNameContainsMoreThanSpecialChars(parsedURL.pathname) || parsedURL.pathname === "/" || parsedURL.pathname === "" ? undefined