Provides URL encoding/decoding and generation functions.
Add the following to your rebar.config:
{ url, ".*", { git, "git://github.com/wrren/url.erl.git", { branch, "master" } } }
%% URL Generation
"http://localhost/hello" = url:join( "http://localhost", ["hello"] ),
"http://localhost/hello" = url:join( "http://localhost/", ["hello"] ),
"http://localhost/hello/goodbye" = url:join( "http://localhost/", ["hello", "goodbye"] ),
"http://localhost/hello?yo=dawg" = url:join( "http://localhost/", ["hello"], #{ "yo" => "dawg" } ),
"http://localhost/hello?yo=dawg" = url:join( "http://localhost", ["hello"], #{ "yo" => "dawg" } ),
"http://localhost/hello?yo=dawg" = url:join( "http://localhost/", ["hello"], [{"yo", "dawg"}] ).
%% URL Encoding
<<"http%3A%2F%2Flocalhost%3A8080%2Fcallback">> = url:encode( "http://localhost:8080/callback" ).
%% URL Decoding
<<"http://localhost:8080/callback">> = url:decode( <<"http%3A%2F%2Flocalhost%3A8080%2Fcallback">> ).
Given a base URL, path components and query parameters (proplist or map), form a full URL.
url:join( BaseUrl :: string(), PathComponents :: [string()], QueryParameters :: map() | [{ string(), string() }] ) -> URL :: string().
Encodes special characters using percent-encoding, allowing them to be sent as part of a URL.
url:encode( string() ) -> binary().
Decodes a URL that's been encoded using the encode function.
url:decode( binary() ) -> string().