Skip to content

fix(utils): let profile URL regexps accept a trailing slash, query or fragment - #3344

Merged
soxoj merged 1 commit into
soxoj:mainfrom
kevin9327:fix/url-regexp-trailing-slash-query
Nov 11, 2026
Merged

soxoj merged 1 commit into
soxoj:mainfrom
kevin9327:fix/url-regexp-trailing-slash-query

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

URLMatcher.make_profile_url_regexp builds ^https?://(www\.|m\.)?<site>/<prefix>(?P<_maigret_username>...)$, so the username has to run all the way to the end of the link. Profile links found on pages (ids_links, which go through extract_ids_from_url) often don't:

  • For a site with a regexCheck, https://github.com/soxoj/ or https://github.com/soxoj?tab=repositories doesn't match at all, so the username is lost.
  • For a site without one, the default .+? swallows the rest: https://site.com/u/bob?ref=share gives the username bob?ref=share, which then gets searched on every site.

This allows an optional trailing slash and an optional ?query / #fragment after the username. Links that matched before still give the same username (a bare trailing slash was already stripped in detect_username), and characters the username regexp rejects still don't match.

Testing: new test_url_make_profile_url_regexp_allows_slash_query_and_fragment fails on main and passes with the change; the two tests that pin the exact pattern (test_url_make_profile_url_regexp, test_site_url_detector) are updated. Full pytest tests/: 554 passed, 5 skipped; the one failure, test_submit.py::test_check_features_manually_cloudflare, fails on main too.

This PR was prepared with AI assistance; I reviewed the change and ran the tests.

@soxoj
soxoj merged commit 843053f into soxoj:main Nov 11, 2026
7 checks passed
@soxoj

soxoj commented Nov 11, 2026

Copy link
Copy Markdown
Owner

@kevin9327 thanks, clean fix 👍

Appreciate the test that fails on main, and that old links still give the same username. I checked it on every site in the base.

More in the enhancement label if you want another. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants