[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 GitHub
parent 39eabc28b5
commit 328b6961a2

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);
};