Skip to content

Commit 799e63b

Browse files
authored
Merge pull request #341 from yozachar/workshop
fix: domain name not confirming to rfc_2782
2 parents 7e799eb + c0e29cf commit 799e63b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/validators/domain.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def domain(value: str, /, *, rfc_1034: bool = False, rfc_2782: bool = False):
4242
# First character of the domain
4343
rf"^(?:[a-zA-Z0-9{'_'if rfc_2782 else ''}]"
4444
# Sub domain + hostname
45-
+ rf"(?:[a-zA-Z0-9-_]{{0,61}}[A-Za-z0-9{'_'if rfc_2782 else ''}])?\.)"
45+
+ rf"(?:[a-zA-Z0-9-{'_'if rfc_2782 else ''}]{{0,61}}"
46+
+ rf"[A-Za-z0-9{'_'if rfc_2782 else ''}])?\.)"
4647
# First 61 characters of the gTLD
4748
+ r"+[A-Za-z0-9][A-Za-z0-9-_]{0,61}"
4849
# Last character of the gTLD

tests/test_domain.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
("value", "rfc_1034", "rfc_2782"),
1212
[
1313
("example.com", False, False),
14+
("exa_mple.com", False, True),
1415
("xn----gtbspbbmkef.xn--p1ai", False, False),
15-
("underscore_subdomain.example.com", False, False),
16+
("underscore_subdomain.example.com", False, True),
1617
("something.versicherung", False, False),
1718
("someThing.versicherung.", True, False),
1819
("11.com", False, False),

0 commit comments

Comments
 (0)