/** * Utility functions for the application. */ const isValidDomain = (domain) => { // Regular expression to validate a domain name // 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); } module.exports = { isValidDomain };