A RFC-3986 URI Library for parsing and building URIs
Find a file
Correl Roush a4e0458534 Fix extra slash being added on root path URIs
The following bug was introduced in d6de7e83:

{https, undefined, "www.example.com", 443, "/", undefined, undefined},
  was being built as
"https://www.example.com//"

This corrects the issue by not appending a slash when the root
path ("/") is specified (it should behave the same as passing an
empty ("") path).
2018-04-13 14:02:59 -04:00
bin Change the execution bit for rebar3 2016-01-21 23:28:31 -05:00
docs Move edoc dir to docs 2016-01-22 10:36:12 -05:00
src Fix extra slash being added on root path URIs 2018-04-13 14:02:59 -04:00
test Fix extra slash being added on root path URIs 2018-04-13 14:02:59 -04:00
.editorconfig Implement the initial API 2016-01-21 23:04:34 -05:00
.gitignore Implement the initial API 2016-01-21 23:04:34 -05:00
.travis.yml Update releases for testing 2018-04-06 13:31:42 -04:00
LICENSE Clean up the license 2018-04-06 13:29:17 -04:00
README.md tcp_port() -> inet:port_number(), addressing #4 2018-04-06 13:29:33 -04:00
rebar.config Remove unused include 2016-01-22 10:36:33 -05:00

urilib

RFC-3986 URI Library for Erlang.

Parse and build URIs with automatic percent encoding and plus encoding of query arguments.

Version Downloads Build Status codecov.io

API

Functions

Function Description
build/1 Build a URI from a uri() or url.
parse/1 Parse a URI from a string, returning a uri().
parse/2 Parse a URI, returning the result as either a uri() or url().
percent_decode/1 Decode a percent encoded string value.
percent_encode/1 Percent encode a string value.
percent_encode/2 Percent encode a string value, explicitly stating the desired case for hexidecimal values. Pass uppercase to the second value to have hex values returned as %2F instead of %2f.
plus_decode/1 Decode a percent encoded string value that uses pluses for spaces.
plus_encode/1 Percent encode a string value similar to percent_encode/1, but encodes spaces with a plus (+) instead of %20.
plus_encode/2 Percent encode a string value similar to percent_encode/1, but encodes spaces with a plus (+) instead of %20, explicitly stating the desired case for hexidecimal values. Pass uppercase to the second value to have hex values returned as %2F instead of %2f.

Types

Type Definition
scheme() `http
username() `string()
password() `string()
userinfo() `{username(), password()}
host() string()
authority() {userinfo(), host(), inet:port_number()}
path() string()
query() `[tuple()
fragment() `string()
uri() {scheme(), authority(), path(), query(), fragment()}
url() {scheme(), username(), password(), host(), inet:port_number(), path(), query(), fragment()}

Example Usage

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}).
"http://guest:guest@localhost:15672/api/queues?name=test"

3> urilib:parse("http://guest:guest@localhost:15672/api/queues?name=test").
{http,{{"guest","guest"},"localhost",15672},
      "/api/queues",
      [{"name","test"}],
      undefined}