Skip to content

Ignore URL #fragment when detecting redirects (#3)#9

Open
kochj23 wants to merge 1 commit into
jtatum:masterfrom
kochj23:fix/issue-3-ignore-fragment
Open

Ignore URL #fragment when detecting redirects (#3)#9
kochj23 wants to merge 1 commit into
jtatum:masterfrom
kochj23:fix/issue-3-ignore-fragment

Conversation

@kochj23

@kochj23 kochj23 commented Jul 1, 2026

Copy link
Copy Markdown

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, so response.url comes back without it. parse() then compared the original request URL (with fragment) against the fragment-less final URL, they differed, and a bogus R: redirect note was emitted.

Fix

In plugin.py, strip the fragment from both URLs before comparing them, via a new strip_fragment() helper (same urlsplit/urlunsplit idiom already used elsewhere in fetch_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, so supybot.test/PluginTestCase cannot be imported or run here. I did not run the suite and am not claiming a passing run.

What I did instead:

  • Verified the fix by inspection against the request/final-URL comparison in parse().
  • Fleshed out the previously empty DetrollTestCase stub with a real testStripFragment method 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

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>
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.

Redirect detection should ignore fragments

1 participant