🐞 fix: change url validation to require scheme and allow path
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user