Repository navigation
Conversation
make_absolute_href and make_relative_href parse local paths with urlparse, then rebuild only the path part. Anything urlparse splits off is lost when the source is a relative (or made-relative) local path: "./item.json?v=2" next to /a/b/c/catalog.json became /a/b/c/item.json, and a file named "scene#1.tif" became "scene". Absolute local paths and URLs already kept these parts. Re-attach the params, query and fragment in _make_absolute_href_path and _make_relative_href_path too.
This branch has not been deployed
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.
Follow-up to #1868, this time for local paths.
make_absolute_hrefandmake_relative_hrefrun local paths throughurlparseand then rebuild only the path, so whateverurlparsesplits off is dropped when the source is a relative local path (or is made relative):An absolute local path keeps them (
make_absolute_href("/data/item.json?v=2", ...)returns it unchanged), and so do URLs, so the result depended on whether the href happened to be relative. The#case is the worse one, since it silently points at a different file.The fix re-attaches the params, query and fragment at the end of
_make_absolute_href_pathand_make_relative_href_path, the same way the URL helpers already do.Testing: added cases to
test_make_relative_hrefandtest_make_absolute_href(query,#in a file name,;in a file name, and afile://start href). All 7 new cases fail on main and pass with the change. Fulltests/run: 1066 passed, 18 skipped. ruff, ruff format, mypy and codespell are clean on the touched files.