feat: worker: newAddress if domain is not set, use the first domain (#358)

This commit is contained in:
Dream Hunter
2024-07-22 13:05:50 +08:00
committed by GitHub
parent 60dda7e3fe
commit 163d9451f7
2 changed files with 6 additions and 0 deletions

View File

@@ -40,6 +40,11 @@ export const newAddress = async (
}
// check domain
const allowDomains = checkAllowDomains ? await getAllowDomains(c) : getDomains(c);
// if domain is not set, use the first domain
if (!domain && allowDomains.length > 0) {
domain = allowDomains[0];
}
// check domain is valid
if (!domain || !allowDomains.includes(domain)) {
throw new Error("Invalid domain")
}