Skip to content

Commit

Permalink
moving to a helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
dubwub committed Nov 26, 2024
1 parent 73566b6 commit ca8ec6e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion servers/fdr/src/util/ParsedBaseUrl.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ca8ec6e

Please sign in to comment.