Skip to content

Instantly share code, notes, and snippets.

@DArmstrong87
Created June 9, 2025 16:39
Show Gist options
  • Select an option

  • Save DArmstrong87/4e0b54b9b8a1e45bf5644f52750df028 to your computer and use it in GitHub Desktop.

Select an option

Save DArmstrong87/4e0b54b9b8a1e45bf5644f52750df028 to your computer and use it in GitHub Desktop.
Validate domains and subdomains
const validateDomain = (domain) => {
const domainRegex = /^[A-Za-z0-9-]{1,63}(\.[A-Za-z0-9-]{1,63})*\.[A-Za-z]{2,6}$/mig;
return domainRegex.test(domain)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment