Skip to content

Preserve explicit empty URL queries - #211

Open
Aschenbath wants to merge 1 commit into
python-hyper:masterfrom
Aschenbath:fix/preserve-empty-query-207
Open

Aschenbath wants to merge 1 commit into
python-hyper:masterfrom
Aschenbath:fix/preserve-empty-query-207

Conversation

@Aschenbath

Copy link
Copy Markdown

Resolving ? against http://example.com/path?x=1 currently retains x=1. Parsing and rendering also discard an explicit empty query, losing the distinction required by RFC 3986 section 5.2.2.

Preserve an empty query as one empty key without a value, (("", None),), consistent with the existing representation of empty ampersand-separated query fields. Render the query separator whenever query fields are present. The existing relative-resolution logic then replaces the base query correctly. The query property documentation describes the representation; no new constructor arguments are needed.

Fixes #207.

Validation on Windows / CPython 3.9.25, using the repository-pinned test and lint tools:

  • All four new regression tests fail on the original source. URL/DecodedURL tests and URL doctests pass: 111 tests against the final source and 111 against the installed wheel.
  • Full suite with Hypothesis seed 0: original 134 passed / 1 failed; patched 138 passed / 1 failed. Both fail the same existing test_hostnames_ascii_nolead filtering health check tracked by Tests are failing due to hypothesis filtering #186; no health checks were suppressed.
  • Black and Flake8 pass. Mypy passes on the three changed Python files; the full check emits the identical 16 diagnostics in unchanged Hypothesis files on base and patch.
  • check-manifest, source/wheel builds, and Twine checks pass. The docs build succeeds with five warnings in unchanged configuration/docstrings; Twine retains the existing content-type warning.

AI assistance was used for investigation, implementation, testing, and this description. No human review or hosted CI result is claimed.

Keep absent and empty queries distinct during parsing and rendering so relative references can clear an inherited query. Cover URL and DecodedURL round trips, query operations, and reference resolution.

Fixes python-hyper#207
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.

URL.click('?') retains the base query instead of clearing it

1 participant