use another domain regex pattern to fix domain validation

This commit is contained in:
Viet Huynh
2023-11-20 08:25:01 +07:00
parent 23cab68c19
commit 0478a2f957
+3 -1
View File
@@ -12,7 +12,9 @@ if (!globalThis.fetch) {
* @param {string} value The value to be checked.
*/
export const isValidDomain = (value) =>
/^(?!-)[A-Za-z0-9-]+([\-\.]{1}[a-z0-9]+)*\.[A-Za-z]{2,6}$/.test(value);
/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(
value
);
/**
* Extracts all subdomains from a domain including itself.