diff --git a/README.md b/README.md index abcca87..c0f8621 100644 --- a/README.md +++ b/README.md @@ -33,13 +33,12 @@ Type | Definition `password()` | `string() | undefined` `userinfo()` | `{username(), password()} | undefined` `host()` | `string()` -`tcp_port()` | `integer()` -`authority()` | `{userinfo(), host(), tcp_port()}` +`authority()` | `{userinfo(), host(), inet:port_number()}` `path()` | `string()` `query()` | `[tuple() | string()] | undefined` `fragment()` | `string() | undefined` `uri()` | `{scheme(), authority(), path(), query(), fragment()}` -`url()` | `{scheme(), username(), password(), host(), tcp_port(), path(), query(), fragment()}` +`url()` | `{scheme(), username(), password(), host(), inet:port_number(), path(), query(), fragment()}` ## Example Usage @@ -48,7 +47,7 @@ Eshell V7.2.1 (abort with ^G) 1> urilib:build({http, {{"guest", "guest"}, "localhost", 15672}, "/api/queues", [{"name", "test"}], undefined}). "http://guest:guest@localhost:15672/api/queues?name=test" -2> urilib:build({http, "guest", "guest", "localhost", 15672, "/api/queues", [{"name", "test"}], undefined}). +2> urilib:build({http, "guest", "guest", "localhost", 15672, "/api/queues", [{"name", "test"}], undefined}). "http://guest:guest@localhost:15672/api/queues?name=test" 3> urilib:parse("http://guest:guest@localhost:15672/api/queues?name=test"). diff --git a/src/urilib.erl b/src/urilib.erl index 0ad95e7..fb25df8 100644 --- a/src/urilib.erl +++ b/src/urilib.erl @@ -18,7 +18,6 @@ -export_type([scheme/0, host/0, - tcp_port/0, username/0, password/0, userinfo/0, @@ -37,16 +36,15 @@ -type hexcase() :: uppercase | lowercase. -type scheme() :: http | https | atom(). -type host() :: string(). --type tcp_port() :: integer(). -type username() :: string() | undefined. -type password() :: string() | undefined. -type userinfo() :: {username(), password()} | undefined. --type authority() :: {userinfo(), host(), tcp_port()}. +-type authority() :: {userinfo(), host(), inet:port_number()}. -type path() :: string(). -type query() :: [tuple() | string()] | undefined. -type fragment() :: string() | undefined. -type uri() :: {scheme(), authority(), path(), query(), fragment()}. --type url() :: {scheme(), username(), password(), host(), tcp_port(), path(), query(), fragment()}. +-type url() :: {scheme(), username(), password(), host(), inet:port_number(), path(), query(), fragment()}. -spec build(Value :: uri() | url()) -> string(). %% @doc Build a URI @@ -247,7 +245,7 @@ url_maybe_add_userinfo(Username, Password, URL) -> string:concat(URL, string:concat(string:join([Username, Password], ":"), "@")). --spec url_add_host_and_port(scheme(), host(), tcp_port(), string()) -> string(). +-spec url_add_host_and_port(scheme(), host(), inet:port_number(), string()) -> string(). %% @private url_add_host_and_port(undefined, Host, undefined, URL) -> string:concat(URL, Host);