Skip to content

Commit

Permalink
Merge "[bugfix] extract linktrail for hr-wiki"
Browse files Browse the repository at this point in the history
  • Loading branch information
xqt authored and Gerrit Code Review committed Nov 2, 2024
2 parents 2124a48 + 6952e47 commit 31f8cae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pywikibot/site/_apisite.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,9 @@ def linktrail(self) -> str:
if linktrail == '/^()(.*)$/sD': # empty linktrail
return ''

# T378787
linktrail = linktrail.replace(r'\p{L}', r'[^\W\d_]')

match = re.search(r'\((?:\:\?|\?\:)?\[(?P<pattern>.+?)\]'
r'(?P<letters>(\|.)*)\)?\+\)', linktrail)
if not match:
Expand Down
3 changes: 2 additions & 1 deletion tests/site_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,8 @@ def test_has_linktrail(self):
small_wikis = self.site.family.languages_by_size[-size:]
great_wikis = self.site.family.languages_by_size[:-size]
great_wikis = random.sample(great_wikis, size)
for code in sorted(small_wikis + great_wikis):
# Also test for 'hr' which failed due to T378787
for code in {'hr', *small_wikis, *great_wikis}:
site = pywikibot.Site(code, self.family)
with self.subTest(site=site):
self.assertIsInstance(site.linktrail(), str)
Expand Down

0 comments on commit 31f8cae

Please sign in to comment.