From 83dd84111b4e61201c1a44cb6b94f384563e3a8a Mon Sep 17 00:00:00 2001 From: New Future Date: Sat, 11 Jun 2022 05:58:17 +0800 Subject: [PATCH] Allow subdomains and localhost in new domain validator (#84) * fix subdomain * add localhost --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 47b9713..bee0b4c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -69,7 +69,7 @@ type IReturnData = (IDomainData) & (IReturnCa) & (IRe export async function certificateFor(requestedDomains: string | string[], options: O = {} as O): Promise> { const domains = Array.isArray(requestedDomains) ? requestedDomains : [requestedDomains]; domains.forEach((domain) => { - if (!isValidDomain(domain, { subdomain: false, wildcard: false, allowUnicode: true, topLevel: false })) { + if (domain !== "localhost" && !isValidDomain(domain, { subdomain: true, wildcard: false, allowUnicode: true, topLevel: false })) { throw new Error(`"${domain}" is not a valid domain name.`); } });