49
return '*';
50
}
52
>
if (!/^\*?\.?[a-z0-9.;,)!?:-]+$/.test(normalized)) {
53
return undefined;
54
}
56
>
// Strip common trailing punctuation that may follow a domain in text, e.g. "example.com,".
57
>
const stripped = normalized.replace(/[),;:!?]+$/, '');
58
>
if (!stripped) {
59
return undefined;
60
}
62
const domainToValidate = stripped.startsWith('*.') ? stripped.slice(2) : stripped;
63
if (!/^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)(?:\.(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?))*$/.test(domainToValidate)) {