diff --git a/lib/elixir/lib/uri.ex b/lib/elixir/lib/uri.ex index c05d8c94ba9..9acb61dda85 100644 --- a/lib/elixir/lib/uri.ex +++ b/lib/elixir/lib/uri.ex @@ -907,7 +907,7 @@ defmodule URI do %{rel | path: remove_dot_segments_from_path(rel.path)} end - def merge(base, %URI{host: host} = rel) when host != nil do + def merge(%URI{} = base, %URI{host: host} = rel) when host != nil do %{rel | scheme: base.scheme, path: remove_dot_segments_from_path(rel.path)} end diff --git a/lib/elixir/test/elixir/uri_test.exs b/lib/elixir/test/elixir/uri_test.exs index 8772ec97d3c..e627b0f84a5 100644 --- a/lib/elixir/test/elixir/uri_test.exs +++ b/lib/elixir/test/elixir/uri_test.exs @@ -387,6 +387,9 @@ defmodule URITest do assert URI.merge("http://google.com/foo", "//example.com/baz") |> to_string == "http://example.com/baz" + assert URI.merge("http://google.com/foo", URI.new!("//example.com/baz")) + |> to_string == "http://example.com/baz" + assert URI.merge("http://google.com/foo", "//example.com/.././bar/../../../baz") |> to_string == "http://example.com/baz"