Skip to content

Commit b412f43

Browse files
Use DomainNameValidator.ul instead of hardcoded unicode range
Replace hardcoded unicode letter range with DomainNameValidator.ul for better maintainability and to avoid duplication. Co-Authored-By: Alan Rominger <[email protected]>
1 parent f0d7e5d commit b412f43

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

awx/conf/fields.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from collections import OrderedDict
77

88
# Django
9-
from django.core.validators import URLValidator, _lazy_re_compile
9+
from django.core.validators import URLValidator, DomainNameValidator, _lazy_re_compile
1010
from django.utils.translation import gettext_lazy as _
1111

1212
# Django REST Framework
@@ -160,13 +160,11 @@ def to_internal_value(self, paths):
160160
class URLField(CharField):
161161
# these lines set up a custom regex that allow numbers in the
162162
# top-level domain
163-
# Django 5.2 removed URLValidator.ul, it was \u00a1-\uffff for unicode letters
164-
ul = r'\u00a1-\uffff'
165163

166164
tld_re = (
167165
r'\.' # dot
168166
r'(?!-)' # can't start with a dash
169-
r'(?:[a-z' + ul + r'0-9' + '-]{2,63}' # domain label, this line was changed from the original URLValidator
167+
r'(?:[a-z' + DomainNameValidator.ul + r'0-9' + '-]{2,63}' # domain label, this line was changed from the original URLValidator
170168
r'|xn--[a-z0-9]{1,59})' # or punycode label
171169
r'(?<!-)' # can't end with a dash
172170
r'\.?' # may have a trailing dot

0 commit comments

Comments
 (0)