Ignore URL #fragment when detecting redirects (#3)#9
Open
kochj23 wants to merge 1 commit into
Open
Conversation
A link containing a #fragment (e.g. .../Talos#tp5) was reported as a redirect: the fragment is never sent to the server, so response.url comes back without it and the request/final URL comparison never matched. Strip the fragment from both URLs before comparing, via a new strip_fragment() helper. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Closes #3
Problem
Linking to a page with a
#fragment(e.g.https://wiki.mozilla.org/Buildbot/Talos#tp5) was incorrectly reported as a redirect. The fragment is a client-side anchor and is never sent to the server, soresponse.urlcomes back without it.parse()then compared the original request URL (with fragment) against the fragment-less final URL, they differed, and a bogusR:redirect note was emitted.Fix
In
plugin.py, strip the fragment from both URLs before comparing them, via a newstrip_fragment()helper (sameurlsplit/urlunsplitidiom already used elsewhere infetch_url). Query strings are preserved; only the fragment is dropped.Testing — please read
I could not execute the test suite locally. This is a Python 2 + Supybot plugin and this environment has only Python 3 (no
python2) and no Supybot runtime, sosupybot.test/PluginTestCasecannot be imported or run here. I did not run the suite and am not claiming a passing run.What I did instead:
parse().DetrollTestCasestub with a realtestStripFragmentmethod covering the issue's exact example, fragment equality, and query-string preservation. Its logic is verified by inspection; it should run under a real Py2/Supybot setup.🤖 Generated with Claude Code