Skip to content

Commit

Permalink
Allow shorter domain suffix for just one character
Browse files Browse the repository at this point in the history
- FIX: Allow shorter domain suffix for just one character
- FEATURE: Add unit test for checking short domain suffix

refs #1167
  • Loading branch information
stho authored and diegogangl committed Jan 9, 2025
1 parent 77fc73a commit ba3dbde
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion GTG/core/urlregex.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
UTF_CHARS = r'a-z0-9_\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff'

SUBST_DICT = {
"domain": r'([\.-]|[^\s_\!\.\/])+\.[a-z]{2,}(?::[0-9]+)?',
"domain": r'([\.-]|[^\s_\!\.\/])+\.[a-z]{1,}(?::[0-9]+)?',
"path": r'(?:[\.,]?[%s!\*\'\(\);:&=\+\$/%s#\[\]\-_,~@])' % (
UTF_CHARS, '%'),
"query": r'[a-z0-9!\*\'\(\);:&=\+\$/%#\[\]\-_\.,~]',
Expand Down
4 changes: 4 additions & 0 deletions tests/core/test_urlregex.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ def test_search_does_not_include_preceeding_whitespace(self):
match = urlregex.search("This snippet contains an url with whitespace"
"before it: https://wiki.gnome.org/Apps/GTG/")
self.assertEqual(list(match)[0].group(), "https://wiki.gnome.org/Apps/GTG/")

def test_domain_with_short_suffix(selfs):
match = urlregex.search("https://ticketsystem.company.x/issues/12345")
selfs.assertEqual(list(match)[0].group(), "https://ticketsystem.company.x/issues/12345")

0 comments on commit ba3dbde

Please sign in to comment.