Merge pull request #146 from OMGerCoder/main

Update URL validity check to support port numbers
This commit is contained in:
Seth Burkart
2024-08-05 14:37:12 +10:00
committed by GitHub
@@ -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.-]+(/[\\w.-]*)*$", "i");
const pattern = new RegExp("^(https?:\\/\\/)?[\\w.-]+(?:\\.[\\w.-]+)*(?::\\d+)?(/[\\w.-]*)*$", "i");
return pattern.test(url);
}, []);