Fix leading slash for abspath in joinpath - #62
Conversation
Signed-off-by: Peter Bräuer <pb866.git@gmail.com>
Add tests to add absolut path with and without trailing slash and absolut path with additional part to an empty uri path. Signed-off-by: Peter Bräuer <pb866.git@gmail.com>
|
Is there anything that needs to be done before this can be merged? I think, the failing test has nothing to do with this fix. An alternative fix would be to ensure non-empty URI paths, so the condition that was adjusted in this PR is not needed at all. This is also a workaround for the current situation (without tempering with the package's code), but it would be nice to have a proper resolution one way or the other. |
|
Thanks for the contribution and apologies for the delayed response. What you've implemented here seems reasonable to me and is what I would generally have expected |
|
Thanks @ararslan for your review. I hadn’t considered it a breaking change since URIs claims to obey RFC-3986, which builds on RFC-2396. So I would argue, this PR is a bug fix as it corrects currently incorrectly implemented behaviour. Therefore, even a patch release should be fine. @quinnj do you have other views on this. It would be great to see this getting merged, so I can use it in some other project. |
|
Thanks for the contribution, and sorry this has sat for so long. I agree that the reported There is one related double-slash case I think we should settle before merging. The new condition also changes x = joinpath(URI("file:"), "//server/share")
string(x) # "file://server/share"
x.host # ""
x.path # "//server/share"
URI(string(x)) == x # falseThe serialized form treats Could you handle or reject that case explicitly, or keep absent-authority If you want me to fix/push to this PR directly, I'm happy to do that and we can merge and be on our way (I know it can be weird/ahrd to pick something up after its' been a while) [double-slash case/example found by codex while helping review this; comments are my own] |
|
Thanks @quinnj for the thorough review! You're making an excellent point. But this is currently also not working on master: x = joinpath(URI("file:"), "/a/b/c") # URI("file://a/b/c")
y = URI(string(x)) # URI("file://a/b/c")
x == y # falseSo, there should probably be some regex check that the host includes a dot or whatever rules there are for a host (I'm no URI expert). I have no problems with anybody working on the fix to continue the work on this branch. If I can support in any way to get this on master, let me know. |
joinpath(URI("http://test.com"), "/abs/path") now correctly yields
http://test.com/abs/path instead of http://test.com//abs/path.
Additionally, when the base URI has no authority (host) component, a
joined path beginning with "//" is unrepresentable per RFC 3986 Sec. 3.3
(it would be re-parsed with the first path segment as the authority), so
joinpath now throws an informative ArgumentError in that case. Includes
regression tests for "file:", "file://", empty-URI, and
authority-present cases, and bumps the version to 1.6.3.
Co-authored-by: Peter Bräuer <pb866.git@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
|
This landed via #71 (squash-merged as 0f4ecc3, with co-author credit) — GitHub doesn't allow maintainer pushes to org-owned fork branches, so I carried this branch over to the base repo to finish it. On top of the fix here, joinpath now throws an ArgumentError when the base URI has no authority component and the joined path begins with "//", since such a URI is unrepresentable per RFC 3986 Sec. 3.3 (this also covers the master-branch round-trip issue you pointed out). Registering v1.6.3 now. Thanks @pb866 for the contribution and the patience! |
Currently,
joinpathgives two leading slashes, when an absolute path is joined to an empty URI path. This PR fixes this issue.