Skip to content

fix: preserve trailing slash on relative URLs #80 - #82

Merged
andrii-novikov merged 3 commits into
developmentfrom
fix/preserve-trailing-slash-issue-80
May 14, 2026
Merged

andrii-novikov merged 3 commits into
developmentfrom
fix/preserve-trailing-slash-issue-80

Conversation

@andrii-novikov

Copy link
Copy Markdown
Contributor

Applicable issues

Description of changes

BaseHTTPClient._prepare_url was unconditionally stripping the trailing / from the merged path of relative URLs, breaking DIAL Core endpoints where the slash is semantically meaningful — notably folder listings under /v1/metadata/files/<bucket>/appdata/<app>/, which return 200 with a trailing slash and 404 without.

The .rstrip(b"/") was redundant: base_url is normalized via enforce_trailing_slash, and the relative side is lstrip(b"/")-ed, so the join boundary cannot produce a double slash. The only thing .rstrip could remove was a legitimate trailing slash the caller intended.

Fix removes the .rstrip call. The same change also incidentally corrects:

  • Empty / "/"-only relative URLs no longer erode the base path (/v1//v1).
  • Trailing slash inside a query string (foo?x=1/) is no longer mutated, since httpx.URL.raw_path includes the query.
  • Multiple meaningful trailing slashes are preserved instead of collapsed.

Added tests/test_prepare_url.py covering trailing-slash preservation across Dial / AsyncDial, the no-slash baseline, and the query-string case.

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@andrii-novikov
andrii-novikov requested a review from adubovik as a code owner May 13, 2026 11:31
BaseHTTPClient._prepare_url was stripping the trailing `/` from the
joined path, breaking endpoints where the slash is semantically
meaningful (e.g. folder listings under `/v1/metadata/files/...`).
The rstrip was redundant — `lstrip` on the relative side already
handles the join boundary against the always-trailing-slash base_url.
@andrii-novikov
andrii-novikov force-pushed the fix/preserve-trailing-slash-issue-80 branch from 04fea39 to 4063ec0 Compare May 13, 2026 11:32
@andrii-novikov
andrii-novikov force-pushed the fix/preserve-trailing-slash-issue-80 branch from cfa4a98 to a90776c Compare May 13, 2026 11:42
@andrii-novikov
andrii-novikov requested a review from korotaav48 May 13, 2026 11:45
@andrii-novikov
andrii-novikov merged commit 631ef65 into development May 14, 2026
10 checks passed
@andrii-novikov
andrii-novikov deleted the fix/preserve-trailing-slash-issue-80 branch May 14, 2026 08:02
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.

Trailing slash stripped from relative URLs in BaseHTTPClient._prepare_url

3 participants