Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix leading slash for abspath in joinpath #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/URIs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ function Base.joinpath(uri::URI, parts::String...)
end
end

if isempty(uri.path)
if isempty(uri.path) && !startswith(path, "/")
path = "/" * path
end
return URI(uri; path=normpath(path))
Expand Down
5 changes: 4 additions & 1 deletion test/uri.jl
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ urltests = URLTest[
@test URIs.splitpath("/foo/bar") == ["foo", "bar"]
end
end

@testset "splitfilepath" begin
@static if Sys.iswindows()
data = [
Expand Down Expand Up @@ -597,6 +597,9 @@ urltests = URLTest[
@test joinpath(URIs.URI("http://a.b.c/d/f"), "/b", "c") == URI("http://a.b.c/b/c")
@test joinpath(URIs.URI("http://a.b.c/"), "b", "c") == URI("http://a.b.c/b/c")
@test joinpath(URIs.URI("http://a.b.c"), "b", "c") == URI("http://a.b.c/b/c")
@test joinpath(URIs.URI("http://a.b.c"), "/b/c/") == URI("http://a.b.c/b/c/")
@test joinpath(URIs.URI("http://a.b.c"), "/b/c") == URI("http://a.b.c/b/c")
@test joinpath(URIs.URI("http://a.b.c"), "/b", "c") == URI("http://a.b.c/b/c")
end

@testset "resolvereference" begin
Expand Down
Loading