Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hostname should support Internationalized domain name (IDN) TLDs #94

Open
candita opened this issue Jan 12, 2022 · 3 comments
Open

Hostname should support Internationalized domain name (IDN) TLDs #94

candita opened this issue Jan 12, 2022 · 3 comments

Comments

@candita
Copy link

candita commented Jan 12, 2022

Hostname RegEx should support a TLD that exists in the IANA list of TLDs at http://data.iana.org/TLD/tlds-alpha-by-domain.txt,
e.g. XN--11B4C3D, or कॉम.

Currently it disallows numbers and hyphen in the last label of the Hostname (TLD):
^([a-zA-Z0-9\p{S}\p{L}]((-?[a-zA-Z0-9\p{S}\p{L}]{0,62})?)|([a-zA-Z0-9\p{S}\p{L}](([a-zA-Z0-9-\p{S}\p{L}]{0,61}[a-zA-Z0-9\p{S}\p{L}])?)(\.)){1,}([a-zA-Z\p{L}]){2,63})$

Can I change it to allow digits and hyphens in the TLD, or create a new format called HostnameIDN?
^([a-zA-Z0-9\p{S}\p{L}]((-?[a-zA-Z0-9\p{S}\p{L}]{0,62})?)|([a-zA-Z0-9\p{S}\p{L}](([a-zA-Z0-9-\p{S}\p{L}]{0,61}[a-zA-Z0-9\p{S}\p{L}])?)(\.)){1,}([a-zA-Z0-9-\p{L}]){2,63})$

@casualjim
Copy link
Member

Yeah, but maybe we should just go with https://pkg.go.dev/golang.org/x/net/idna ?

@candita
Copy link
Author

candita commented Jan 13, 2022

You would make the Hostname RegEx obsolete?

@casualjim
Copy link
Member

Yeah, we did the same for email addresses because regex'es are always a bit wonky for these things.
https://github.com/go-openapi/strfmt/blob/master/default.go#L122-L126

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants