Skip to content

Commit 7c7223d

Browse files
authored
allow hyphens in sub domains (#96)
Thanks! Co-authored-by: William Shuman <>
1 parent efcbfe0 commit 7c7223d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

python/py_vapid/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def verify(cls, auth):
352352

353353
def _check_sub(sub):
354354
pattern =(
355-
r"^(mailto:.+@((localhost|[%\w]+(\.[%\w]+)+|([0-9a-f]{1,4}):+([0-9a-f]{1,4})?)))|https:\/\/(localhost|\w+\.[\w\.]+|([0-9a-f]{1,4}:+)+([0-9a-f]{1,4})?)$"
355+
r"^(mailto:.+@((localhost|[%\w-]+(\.[%\w-]+)+|([0-9a-f]{1,4}):+([0-9a-f]{1,4})?)))|https:\/\/(localhost|[\w-]+\.[\w\.-]+|([0-9a-f]{1,4}:+)+([0-9a-f]{1,4})?)$"
356356
)
357357
return re.match(pattern, sub, re.IGNORECASE) is not None
358358

python/py_vapid/tests/test_vapid.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ def test_sub(self):
260260
'mailto:me@1234::',
261261
'mailto:me@1234::5678',
262262
263+
263264
'https://localhost',
265+
'https://exmample-test-case.test.org',
264266
'https://8001::',
265267
'https://8001:1000:0001',
266268
'https://1.2.3.4'
@@ -277,4 +279,4 @@ def test_sub(self):
277279
for val in valid:
278280
assert _check_sub(val) is True
279281
for val in invalid:
280-
assert _check_sub(val) is False
282+
assert _check_sub(val) is False

0 commit comments

Comments
 (0)