Skip to content

Clear base fragments when clicking empty references - #209

Open
theman6660 wants to merge 1 commit into
python-hyper:masterfrom
theman6660:codex/clear-fragment-on-empty-click
Open

theman6660 wants to merge 1 commit into
python-hyper:masterfrom
theman6660:codex/clear-fragment-on-empty-click

Conversation

@theman6660

Copy link
Copy Markdown

When the base URL has a fragment, click("") and click() retain it, while click(URL()) clears it. For example, URL.from_text("http://example.com/a/b?x=1#old").click("") returns the URL with #old still attached.

Clear the base fragment in the empty-text/default-argument branch, retaining the existing path/query and dot-segment handling. This agrees with the structured empty-reference behavior and RFC 3986 section 5.2.2, where the target fragment comes from the reference. Node's URL resolution also drops the old fragment for an empty reference.

Regression tests cover URL and DecodedURL, default/empty-text/structured empty references, base queries, dot segments, explicit fragment replacement/clearing, and base immutability. This is independent of #208 and is based directly on upstream master.

Validation on Windows / Python 3.12.10:

  • Both new regression tests failed against original source; all 89 URL/DecodedURL tests pass with the fix.
  • Tests and module doctests: 134 passed, 3 deselected. These three hostname-strategy tests hit Hypothesis filtering health checks on pristine upstream 978f2e6 too (previously verified in the same environment; see Tests are failing due to hypothesis filtering #186). No full-suite green claim.
  • Black 21.7b0 on changed files and git diff --check pass. Older interpreter matrix not run.

Found during source inspection. Implementation, tests, and this description were prepared with OpenAI Codex at my request.

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.

1 participant