Skip to content

Commit

Permalink
Small change to domain RE (#76)
Browse files Browse the repository at this point in the history
* Update domain.py

Removing [.] from in the regex and added a non capturing group for it.

* Update test_domain.py

Added the following test case `a......b.com` to invalid domains.

* `+` and not a `*`

* removed extra `,`

* Update test_domain.py

removed extra lines.
  • Loading branch information
Ni-Knight authored and kvesteri committed Jun 3, 2018
1 parent d8a5c21 commit fa3cb28
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions tests/test_domain.py
Expand Up @@ -23,6 +23,7 @@ def test_returns_true_on_valid_domain(value):
'example.',
'-example.com',
'example',
'a......b.com'
])
def test_returns_failed_validation_on_invalid_domain(value):
assert isinstance(domain(value), ValidationFailure)
4 changes: 2 additions & 2 deletions validators/domain.py
Expand Up @@ -3,9 +3,9 @@
from .utils import validator

pattern = re.compile(
r'^(([a-zA-Z]{1})|([a-zA-Z]{1}[a-zA-Z]{1})|' # domain pt.1
r'^(:?(([a-zA-Z]{1})|([a-zA-Z]{1}[a-zA-Z]{1})|' # domain pt.1
r'([a-zA-Z]{1}[0-9]{1})|([0-9]{1}[a-zA-Z]{1})|' # domain pt.2
r'([a-zA-Z0-9][-_.a-zA-Z0-9]{0,61}[a-zA-Z0-9]))\.' # domain pt.3
r'([a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]))\.)+' # domain pt.3
r'([a-zA-Z]{2,13}|(xn--[a-zA-Z0-9]{2,30}))$' # TLD
)

Expand Down

0 comments on commit fa3cb28

Please sign in to comment.