Skip to content

Commit b096b50

Browse files
authored
Fix URI.merge/2 handling of authorityless base (#14358)
* Fix URI.merge/2 handling of base without authority * Organize URI.merge/2 tests in describe block
1 parent 05855af commit b096b50

File tree

2 files changed

+301
-279
lines changed

2 files changed

+301
-279
lines changed

lib/elixir/lib/uri.ex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,15 @@ defmodule URI do
919919
%{base | query: rel.query || base.query, fragment: rel.fragment}
920920
end
921921

922+
def merge(%URI{host: nil, path: nil} = base, %URI{} = rel) do
923+
%{
924+
base
925+
| path: remove_dot_segments_from_path(rel.path),
926+
query: rel.query,
927+
fragment: rel.fragment
928+
}
929+
end
930+
922931
def merge(%URI{} = base, %URI{} = rel) do
923932
new_path = merge_paths(base.path, rel.path)
924933
%{base | path: new_path, query: rel.query, fragment: rel.fragment}

0 commit comments

Comments
 (0)