fix: Inefficient regular expression #147

This commit is contained in:
sethburkart123
2024-08-14 16:15:11 +10:00
parent f9c2f5876f
commit 0873a33da2
@@ -28,7 +28,7 @@ const Shortcuts = memo(() => {
const isValidTitle = useCallback((title: string) => title.trim() !== "", []);
const isValidURL = useCallback((url: string) => {
const pattern = new RegExp("^(https?:\\/\\/)?[\\w.-]+(?:\\.[\\w.-]+)*(?::\\d+)?(/[\\w.-]*)*$", "i");
const pattern = new RegExp("^(https?:\\/\\/)?[\\w.-]+(?:\\.[\\w\\-]+)*(?::\\d+)?(/[\\w\\-./]*)*$", "i");
return pattern.test(url);
}, []);