Skip to content

Commit

Permalink
refactored regex on helpUtils validateAgencyURL function
Browse files Browse the repository at this point in the history
  • Loading branch information
corypride committed May 10, 2024
1 parent 5b36339 commit 1c27f6c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion common/utils/helperUtils.ts
Expand Up @@ -281,7 +281,8 @@ export const validateEmail = (email: string | undefined) => {
};

export const validateAgencyURL = (url: string) => {
const urlRegex = /^(?:https?|ftp):\/\/(?:[\w.-]+\.)+[a-zA-Z]{2,}(?:\/\S*)?$/;
const urlRegex =
/^(?:(?:https?|ftp):\/\/)?(?:[\w.-]{1,63}\.){1,}[a-zA-Z]{2,}(?:\/\S*)?$/;

Check failure

Code scanning / CodeQL

Inefficient regular expression High

This part of the regular expression may cause exponential backtracking on strings containing many repetitions of '-.'.
return urlRegex.test(url);
};

Expand Down

0 comments on commit 1c27f6c

Please sign in to comment.