Skip to content

Commit 297f42a

Browse files
Adds support for emojis and more IDNA URLs
1 parent 99ea4da commit 297f42a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

tests/test_url.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
u'http://مثال.إختبار',
4343
u'http://例子.测试',
4444
u'http://उदाहरण.परीक्षा',
45+
u'http://www.😉.com',
46+
u'http://😉.com/😁',
47+
u'http://উদাহরণ.বাংলা',
48+
u'http://xn--d5b6ci4b4b3a.xn--54b7fta0cc',
4549
u'http://-.~_!$&\'()*+,;=:%40:80%2f::::::@example.com',
4650
u'http://1337.net',
4751
u'http://a.b-c.de',

validators/url.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@
6969
r"(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])"
7070
r")\]|"
7171
# host name
72-
r"(?:(?:[a-z\u00a1-\uffff0-9]-?)*[a-z\u00a1-\uffff0-9]+)"
72+
r"(?:(?:(?:xn--)|[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]-?)*[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]+)"
7373
# domain name
74-
r"(?:\.(?:[a-z\u00a1-\uffff0-9]-?)*[a-z\u00a1-\uffff0-9]+)*"
74+
r"(?:\.(?:(?:xn--)|[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]-?)*[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]+)*"
7575
# TLD identifier
76-
r"(?:\.(?:[a-z\u00a1-\uffff]{2,}))"
76+
r"(?:\.(?:(?:xn--[a-z\u00a1-\uffff\U00010000-\U0010ffff0-9]{2,})|[a-z\u00a1-\uffff\U00010000-\U0010ffff]{2,}))"
7777
r")"
7878
# port number
7979
r"(?::\d{2,5})?"
8080
# resource path
81-
u"(?:/[-a-z\u00a1-\uffff0-9._~%!$&'()*+,;=:@/]*)?"
81+
u"(?:/[-a-z\u00a1-\uffff\U00010000-\U0010ffff0-9._~%!$&'()*+,;=:@/]*)?"
8282
# query string
8383
r"(?:\?\S*)?"
8484
# fragment

0 commit comments

Comments
 (0)