Don't use urljoin for prepending a forward slash to paths.#302
Merged
lundberg merged 1 commit intolundberg:masterfrom Nov 17, 2025
Merged
Don't use urljoin for prepending a forward slash to paths.#302lundberg merged 1 commit intolundberg:masterfrom
lundberg merged 1 commit intolundberg:masterfrom
Conversation
Fixes lundberg#273. Previously, `Path` used `urljoin` to prepend a forward slash to the path. But `urljoin` is broken for no good reason: >>> from urllib.parse import urljoin >>> urljoin("/", "oh//no") '/oh/no' Fix this by just adding a "/" if it's not there, which is what this was trying to do in the first place.
Owner
|
Looks good! Thanks @lewiscollard |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #302 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 22 22
Lines 2933 2934 +1
Branches 199 200 +1
=========================================
+ Hits 2933 2934 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thanks @lundberg! Would there be any chance of a new release please? Though I fully appreciate life can be busy. We have a test that fails intermittently when there are 2 sequential slashes in a base64 value that ends up in the URL (don't ask...!) |
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.
Fixes #273.
Previously,
Pathusedurljointo prepend a forward slash to the path. Buturljoin, for no good reason I can see, breaks if you have two slashes in a path:This manifests itself as respx asserting that routes were not called if they contained two forward slashes in the path part. Fix this by just adding a "/" if it's not there, which is what this was trying to do in the first place.