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

Fixes error with international URLs that have more than 2 hyphens #184

Merged
merged 8 commits into from Jun 5, 2022
2 changes: 2 additions & 0 deletions tests/test_url.py
Expand Up @@ -46,6 +46,8 @@
u'http://😉.com/😁',
u'http://উদাহরণ.বাংলা',
u'http://xn--d5b6ci4b4b3a.xn--54b7fta0cc',
u'http://дом-м.рф/1/asdf',
u'http://xn----gtbybh.xn--p1ai/1/asdf',
u'http://-.~_!$&\'()*+,;=:%40:80%2f::::::@example.com',
u'http://1337.net',
u'http://a.b-c.de',
Expand Down
6 changes: 3 additions & 3 deletions validators/url.py
Expand Up @@ -69,13 +69,13 @@
r"(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])"
r")\]|"
# host name
r"(?:(?:(?:xn--)|[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]-?)*"
r"(?:(?:(?:xn--[-]{0,2})|[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]-?)*"
r"[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]+)"
# domain name
r"(?:\.(?:(?:xn--)|[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]-?)*"
r"(?:\.(?:(?:xn--[-]{0,2})|[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]-?)*"
r"[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]+)*"
# TLD identifier
r"(?:\.(?:(?:xn--[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]{2,})|"
r"(?:\.(?:(?:xn--[-]{0,2}[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]{2,})|"
r"[a-z\u00a1-\uffff\U00010000-\U0010ffff]{2,}))"
r")"
# port number
Expand Down