diff --git a/tests/test_url.py b/tests/test_url.py index 8fcc67be..2252f24d 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -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', diff --git a/validators/url.py b/validators/url.py index fe2cbf53..37d946cb 100644 --- a/validators/url.py +++ b/validators/url.py @@ -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