fix: allow for undescores and leading hyphens in domain validator (#1088)

This commit is contained in:
Stavros
2026-08-22 19:59:53 +03:00
committed by GitHub
parent cf5d5cab6e
commit 4dc12c677c
2 changed files with 22 additions and 4 deletions
+9 -1
View File
@@ -119,7 +119,15 @@ func (v *DomainValidator) getHostname(hostname string) (string, error) {
if net.ParseIP(hostname) != nil {
return "", fmt.Errorf("ip addresses are not supported")
}
hostname, err := idna.Lookup.ToASCII(hostname)
i := idna.New(
idna.MapForLookup(),
idna.Transitional(false),
idna.BidiRule(),
idna.StrictDomainName(false),
idna.CheckHyphens(false),
idna.CheckJoiners(false),
)
hostname, err := i.ToASCII(hostname)
if err != nil {
return "", fmt.Errorf("failed to convert hostname to ascii: %w", err)
}