File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 10
10
'underscore_subdomain.example.com',
11
11
'something.versicherung',
12
12
'11.com',
13
+ '3.cn',
14
+ 'a.cn',
15
+ 'sub1.sub2.sample.co.uk',
13
16
'somerandomexample.xn--fiqs8s'
14
17
])
15
18
def test_returns_true_on_valid_domain(value):
@@ -22,6 +25,9 @@ def test_returns_true_on_valid_domain(value):
22
25
'example.-com',
23
26
'example.',
24
27
'-example.com',
28
+ 'example-.com',
29
+ '_example.com',
30
+ 'example_.com',
25
31
'example',
26
32
'a......b.com'
27
33
])
Original file line number Diff line number Diff line change 3
3
from .utils import validator
4
4
5
5
pattern = re.compile(
6
- r'^(:?(( [a-zA-Z]{1})|([a-zA-Z]{1}[a-zA-Z]{1})| ' # domain pt.1
7
- r'([a-zA-Z]{1}[0-9]{1})|([0-9]{1 }[a-zA-Z]{1})| ' # domain pt.2
8
- r'( [a-zA-Z0- 9][-_a-zA-Z0-9 ]{0,61}[a-zA-Z0-9]))\.)+ ' # domain pt.3
9
- r'( [a-zA-Z]{2,13}|(xn--[a-zA-Z0-9]{2,30})) $' # TLD
6
+ r'^(?: [a-z0-9] ' # First character of the domain
7
+ r'(?: [a-z0-9-_]{0,61 }[a-z0-9])?\.) ' # Sub domain + hostname
8
+ r'+ [a-z0- 9][a-z0-9-_ ]{0,61}' # First 61 characters of the gTLD
9
+ r'[a-z0-9] $' # Last character of the gTLD
10
10
)
11
11
12
12
You can’t perform that action at this time.
0 commit comments