🐞 fix: change url validation to require scheme and allow path

This commit is contained in:
Keith Solomon
2025-05-29 07:15:29 -05:00
parent de88a320d7
commit c6070dffeb
4 changed files with 8 additions and 1369 deletions

View File

@@ -4,7 +4,11 @@
const isValidDomain = (domain) => {
// Regular expression to validate a domain name
const domainRegex = /^(?!:\/\/)([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/;
// const domainRegex = /^(?!:\/\/)([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/;
// Regular expression to validate a domain name. Requires http or https prefix.
// Allows for optional path after the domain.
const domainRegex = /^https?:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(\/[^\s]*)?\/?$/;
return domainRegex.test(domain);
}