diff --git a/src/woody.erl b/src/woody.erl index 3d5f936..2547382 100644 --- a/src/woody.erl +++ b/src/woody.erl @@ -46,7 +46,7 @@ -export_type([handler/1, ev_handler/0, options/0]). -type role() :: client | server. --type url() :: string(). %% http://erlang.org/doc/man/httpc.html#http-data-types +-type url() :: binary() | string(). -type path() :: '_' | iodata(). %% cowboy_router:route_match() -type http_handler(Handler) :: {path(), Handler}. -export_type([role/0, url/0, path/0, http_handler/1]). diff --git a/src/woody_resolver.erl b/src/woody_resolver.erl index 7719052..9c98454 100644 --- a/src/woody_resolver.erl +++ b/src/woody_resolver.erl @@ -5,7 +5,7 @@ -include_lib("kernel/include/inet.hrl"). -include_lib("hackney/include/hackney_lib.hrl"). --type url() :: binary() | nonempty_string(). +-type url() :: woody:url(). -type parsed_url() :: #hackney_url{}. -type resolve_result() :: {Old::parsed_url(), New::parsed_url()}. @@ -42,7 +42,7 @@ resolve_url(Url, WoodyState) -> {ok, resolve_result()} | {error, Reason :: atom()}. resolve_url(Url, WoodyState, Opts) when is_list(Url) -> - resolve_url(list_to_binary(Url), WoodyState, Opts); + resolve_url(unicode:characters_to_binary(Url), WoodyState, Opts); resolve_url(<<"https://", _Rest/binary>> = Url, WoodyState, Opts) -> resolve_parsed_url(parse_url(Url), WoodyState, Opts); resolve_url(<<"http://", _Rest/binary>> = Url, WoodyState, Opts) ->