Skip to content

Commit 3f2ded0

Browse files
committed
Handle :port :undefined on URI.new
1 parent d600406 commit 3f2ded0

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/elixir/lib/uri.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ defmodule URI do
648648
scheme = String.downcase(scheme, :ascii)
649649

650650
case map do
651-
%{port: _} ->
651+
%{port: port} when port != :undefined ->
652652
%{uri | scheme: scheme}
653653

654654
%{} ->

lib/elixir/test/elixir/uri_test.exs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,31 @@ defmodule URITest do
279279
end
280280
end
281281

282+
test "http://http://http://@http://http://?http://#http://" do
283+
assert URI.parse("http://http://http://@http://http://?http://#http://") ==
284+
%URI{
285+
scheme: "http",
286+
authority: "http:",
287+
userinfo: nil,
288+
host: "http",
289+
port: 80,
290+
path: "//http://@http://http://",
291+
query: "http://",
292+
fragment: "http://"
293+
}
294+
295+
assert URI.new!("http://http://http://@http://http://?http://#http://") ==
296+
%URI{
297+
scheme: "http",
298+
userinfo: nil,
299+
host: "http",
300+
port: 80,
301+
path: "//http://@http://http://",
302+
query: "http://",
303+
fragment: "http://"
304+
}
305+
end
306+
282307
test "default_port/1,2" do
283308
assert URI.default_port("http") == 80
284309

0 commit comments

Comments
 (0)