FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Reject an underscore in the last domain label by SashaMIT · Pull Request #485 · python-validators/validators · GitHub

Repository navigation

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .md  (1) .py  (2) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 6 additions & 0 deletions CHANGES.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Note to self: Breaking changes must increment either

-->

## Unreleased

_**Fixes**_

* Reject an underscore in the last domain label. ([#484](https://github.com/python-validators/validators/issues/484))

## 0.35.0 (2025-05-01)

_**Breaking**_ ⚠️
Expand Down
5 changes: 3 additions & 2 deletions src/validators/domain.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ def domain(
+ rf"(?:[a-z0-9-{service_record}]{{0,61}}"
# Hostname
+ rf"[a-z0-9{service_record}])?\.)"
# First 61 characters of the gTLD
+ r"+[a-z0-9][a-z0-9-_]{0,61}"
# First 61 characters of the gTLD. An underscore belongs
# in a service label, not here.
+ r"+[a-z0-9][a-z0-9-]{0,61}"
# Last character of the gTLD
+ rf"[a-z]{trailing_dot}",
value.encode("idna").decode("utf-8"),
Expand Down
3 changes: 3 additions & 0 deletions tests/test_domain.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def test_returns_true_on_valid_top_level_domain(
("__exa__mple__.com", False, True),
("a......b.com", False, False),
("a.123", False, False),
("foo.ba_r", False, False),
("foo.ba_r", False, True),
("example.co_uk", False, False),
("123.123", False, False),
("123.123.123.", True, False),
("123.123.123.123", False, False),
Expand Down

Back | FazBrowse Home | New Git URL