From 0a791b6a8a0a8e448b2de5148a03b356aabb891f Mon Sep 17 00:00:00 2001 From: davidt99 Date: Sun, 15 Sep 2024 14:35:04 +0300 Subject: [PATCH] fix(domain): accept .onion as a valid TLD --- src/validators/domain.py | 1 + tests/test_domain.py | 1 + 2 files changed, 2 insertions(+) diff --git a/src/validators/domain.py b/src/validators/domain.py index 23ae263d..384ade0f 100644 --- a/src/validators/domain.py +++ b/src/validators/domain.py @@ -16,6 +16,7 @@ class _IanaTLD: _full_cache: Optional[Set[str]] = None # source: https://www.statista.com/statistics/265677 _popular_cache = {"COM", "ORG", "RU", "DE", "NET", "BR", "UK", "JP", "FR", "IT"} + _popular_cache.add("ONION") @classmethod def _retrieve(cls): diff --git a/tests/test_domain.py b/tests/test_domain.py index 6d8e8675..63342f76 100644 --- a/tests/test_domain.py +++ b/tests/test_domain.py @@ -46,6 +46,7 @@ def test_returns_true_on_valid_domain(value: str, rfc_1034: bool, rfc_2782: bool ("_example.com", True, False, True), ("example_.com", True, False, True), ("somerandomexample.xn--fiqs8s", True, False, False), + ("somerandomexample.onion", True, False, False), ], ) def test_returns_true_on_valid_top_level_domain(