From f9ad5d8772e322121cdf982aff21d9a3b40a6718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Br=C3=A4uer?= Date: Sat, 28 Dec 2024 22:56:21 +0100 Subject: [PATCH 1/2] Fix leading slash for abspath in joinpath MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peter Bräuer --- src/URIs.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/URIs.jl b/src/URIs.jl index ef45207..eb848f3 100644 --- a/src/URIs.jl +++ b/src/URIs.jl @@ -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)) From a9506cd4f693b01aecc691bcacf00399c25a07e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Br=C3=A4uer?= Date: Sat, 28 Dec 2024 23:08:54 +0100 Subject: [PATCH 2/2] Add unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- test/uri.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/uri.jl b/test/uri.jl index 47e11c3..b291e85 100644 --- a/test/uri.jl +++ b/test/uri.jl @@ -462,7 +462,7 @@ urltests = URLTest[ @test URIs.splitpath("/foo/bar") == ["foo", "bar"] end end - + @testset "splitfilepath" begin @static if Sys.iswindows() data = [ @@ -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