Repository navigation
fix(utils): let profile URL regexps accept a trailing slash, query or fragment - #3344
Merged
Merged
Conversation
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
URLMatcher.make_profile_url_regexpbuilds^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 throughextract_ids_from_url) often don't:regexCheck,https://github.com/soxoj/orhttps://github.com/soxoj?tab=repositoriesdoesn't match at all, so the username is lost..+?swallows the rest:https://site.com/u/bob?ref=sharegives the usernamebob?ref=share, which then gets searched on every site.This allows an optional trailing slash and an optional
?query/#fragmentafter the username. Links that matched before still give the same username (a bare trailing slash was already stripped indetect_username), and characters the username regexp rejects still don't match.Testing: new
test_url_make_profile_url_regexp_allows_slash_query_and_fragmentfails onmainand passes with the change; the two tests that pin the exact pattern (test_url_make_profile_url_regexp,test_site_url_detector) are updated. Fullpytest tests/: 554 passed, 5 skipped; the one failure,test_submit.py::test_check_features_manually_cloudflare, fails onmaintoo.This PR was prepared with AI assistance; I reviewed the change and ran the tests.