Skip to content

Commit

Permalink
Fixed restrictive URL sanity check #6570
Browse files Browse the repository at this point in the history
Changes
- Replaced the old regex with a new, more inclusive regex pattern.
- Updated the isURL function to use the new pattern.
  • Loading branch information
AnanteshG committed Aug 7, 2024
1 parent 1b9f63b commit f760f07
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/twenty-front/src/utils/is-url.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { isDefined } from './isDefined';

export const isURL = (url: string | undefined | null) =>
isDefined(url) &&
url.match(
/^(https?:\/\/)?(www.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/i,
);
export const isURL = (url: string | undefined | null): boolean => {
if (!isDefined(url)) {
return false;
}

const urlRegex = /^(https?:\/\/)?([\w-]+\.)+[\w-]+(\:\d+)?(\/[\w\-\.~%!$&'()*+,;=:@/]*)?(\?[;&a-z\-\_=\+%]+)?(#\S*)?$/i;

return urlRegex.test(url);
};

0 comments on commit f760f07

Please sign in to comment.