Skip to content
Merged
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 lib/elixir/lib/uri.ex
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ defmodule URI do
@spec merge(t | binary, t | binary) :: t
def merge(uri, rel)

def merge(%URI{host: nil}, _rel) do
def merge(%URI{scheme: nil}, _rel) do
raise ArgumentError, "you must merge onto an absolute URI"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this message is correct. Also, shouldn't be fine to merge into //foo/bar? Should we add a test for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the error message: I believe the message has become more accurate with this change. But "base must be an absolute URI" might be clearer.

Regarding //foo/bar: Such a network-path reference, is still a relative URI and should IMO lead to this error when used as a base.

end

Expand Down
5 changes: 5 additions & 0 deletions lib/elixir/test/elixir/uri_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,11 @@ defmodule URITest do
"https://images.example.com/t/1600x/https://images.example.com/foo.jpg"
end

test "merge/2 with host-less URIs" do
assert URI.merge("tag:example", "foo") |> to_string == "tag:foo"
assert URI.merge("tag:example", "#fragment") |> to_string == "tag:example#fragment"
end

test "merge/2 (with RFC examples)" do
# These are examples from:
#
Expand Down
Loading