[WEB-2605] fix: update URL regex pattern to allow complex links. (#5767)

This commit is contained in:
Prateek Shourya 2024-10-08 13:20:27 +05:30 committed by sriram veeraghanta
parent 2b1da96c3f
commit 7495a7d0cb

View file

@ -270,7 +270,7 @@ export const isCommentEmpty = (comment: string | undefined): boolean => {
export const checkURLValidity = (url: string): boolean => {
if (!url) return false;
// regex to match valid URLs (with or without http/https)
const urlPattern = /^(https?:\/\/)?([\da-z.-]+)\.([a-z]{2,6})(\/[\w.-]*)*\/?(\?[=&\w.-]*)?$/i;
const urlPattern = /^(https?:\/\/)?([\w.-]+\.[a-z]{2,6})(\/[\w\-.~:/?#[\]@!$&'()*+,;=%]*)?$/i;
// test if the URL matches the pattern
return urlPattern.test(url);
};