urilib ====== [RFC-3986](https://tools.ietf.org/html/rfc3986) URI Library for Erlang. [![Build Status](https://travis-ci.org/gmr/urilib.svg?branch=master)](https://travis-ci.org/gmr/urilib) [![codecov.io](https://codecov.io/github/gmr/urilib/coverage.svg?branch=master)](https://codecov.io/github/gmr/urilib?branch=master) Example Usage ------------- ```erlang -include_lib("urilib.h"). URI = urilib:parse_uri("http://foo:bar@www.google.com/search?baz=qux#corgie"), io:format("Parsed URI: ~p~n", [URI]). URL = urllib:build(#url{scheme=http, host="www.google.com", path="/search", query=[{"foo", "bar"}], fragment="baz"}), io:format("Built URL: ~s~n", [URL]). ``` Records ------- #### authority #### ```erlang #{host :: string(), port :: integer()}). ``` #### userinfo #### ```erlang #{username :: string(), password :: string()}). ``` #### uri #### ```erlang #{scheme :: atom(), userinfo :: #userinfo{}, authority :: #authority{}, path :: string(), query :: list(), fragment :: string()}). ``` #### url #### ```erlang #{scheme :: atom(), username :: string(), password :: string(), host :: string(), port :: integer(), path :: string(), query :: list(), fragment :: string()}). ``` API --- ### build/1 ### ```erlang build(Uri::Value) -> URI ``` Returns a URI from the record passed in. ### decode/1 ### ```erlang decode(Value) -> DecodedValue ``` Decode a percent encoded string value. ### decode_plus/1 ### ```erlang decode_plus(Value) -> DecodedValue ``` Decode a percent encoded string value that uses pluses for spaces. Note: The use of plus for space is defined in RFC-1630 but does not appear in RFC-3986. ### encode/1 ### ```erlang encode(Value) -> EncodedValue ``` Percent encode a string value. ### encode_plus/1 ### ```erlang encode_plus(Value) -> EncodedValue ``` Percent encode a string value similar to encode/1, but encodes spaces with a plus (+) instead of %20. This function can be used for encoding query arguments. Note: The use of plus for space is defined in RFC-1630 but does not appear in RFC-3986. ### parse_uri/1 ### ```erlang parse_uri(URI) -> ParsedURI ``` Parse a URI string returning the parsed data as a record ### parse_url/1 ### ```erlang parse_url(URL) -> ParsedURL ``` Parse a URL string returning the parsed data as a record