Skip to content

Commit b477dba

Browse files
author
José Valim
committed
Improve docs for URI
Signed-off-by: José Valim <[email protected]>
1 parent 8d524ef commit b477dba

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/elixir/lib/uri.ex

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ defmodule URI do
276276
@doc """
277277
Parses a URI into components.
278278
279+
This parsing is not strict and therefore does not validate the URI.
280+
See the examples section below of how `URI.parse/1` can be used to
281+
parse a wide range of relative URIs.
282+
279283
URIs have portions that are handled specially for the particular
280284
scheme of the URI. For example, http and https have different
281285
default ports. Such values can be accessed and registered via
@@ -288,6 +292,18 @@ defmodule URI do
288292
authority: "elixir-lang.org", userinfo: nil,
289293
host: "elixir-lang.org", port: 80}
290294
295+
iex> URI.parse("//elixir-lang.org/")
296+
%URI{authority: "elixir-lang.org", fragment: nil, host: "elixir-lang.org",
297+
path: "/", port: nil, query: nil, scheme: nil, userinfo: nil}
298+
299+
iex> URI.parse("/foo/bar")
300+
%URI{authority: nil, fragment: nil, host: nil, path: "/foo/bar",
301+
port: nil, query: nil, scheme: nil, userinfo: nil}
302+
303+
iex> URI.parse("foo/bar")
304+
%URI{authority: nil, fragment: nil, host: nil, path: "foo/bar",
305+
port: nil, query: nil, scheme: nil, userinfo: nil}
306+
291307
"""
292308
def parse(%URI{} = uri), do: uri
293309

0 commit comments

Comments
 (0)