From 1ef5815f651ec30d93117c9c1e567201de13e1dc Mon Sep 17 00:00:00 2001 From: Aarish <118203269+ImprobableGenius@users.noreply.github.com> Date: Sat, 24 May 2025 18:36:56 -0500 Subject: [PATCH] domain name validation logic --- helpers/utils.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 helpers/utils.js diff --git a/helpers/utils.js b/helpers/utils.js new file mode 100644 index 0000000..e9e7c46 --- /dev/null +++ b/helpers/utils.js @@ -0,0 +1,13 @@ +/** + * 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,}$/; + return domainRegex.test(domain); +} + +module.exports = { + isValidDomain +};