Skip to content

Commit

Permalink
fix: whitelist rule url validation
Browse files Browse the repository at this point in the history
  • Loading branch information
sereneblue committed Sep 8, 2024
1 parent 81b9385 commit c744ff6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,13 @@ let isInternalIP = (host: string): boolean => {

let isValidURL = (url: string): boolean => {
try {
if (!/^https?:\/\//i.test(url)) {
url = 'http://' + url;
}
new URL(url);
return true; // The URL is valid
return true;
} catch (e) {
return false; // The URL is not valid
return false;
}
};

Expand Down

0 comments on commit c744ff6

Please sign in to comment.