Module urilib

urilib is a RFC-3986 URI Library for Erlang.

Copyright © 2016

Authors: Gavin M. Roy (gavinmroy@gmail.com).

Description

urilib is a RFC-3986 URI Library for Erlang

Data Types

authority()

authority() = {userinfo(), host(), inet:port_number()}

fragment()

fragment() = string() | undefined

hexcase()

hexcase() = uppercase | lowercase

host()

host() = string()

password()

password() = string() | undefined

path()

path() = string()

query()

query() = [tuple() | string()] | undefined

scheme()

scheme() = http | https | atom()

uri()

uri() = {scheme(), authority(), path(), query(), fragment()}

url()

url() = 
    {scheme(),
     username(),
     password(),
     host(),
     inet:port_number(),
     path(),
     query(),
     fragment()}

userinfo()

userinfo() = {username(), password()} | undefined

username()

username() = string() | undefined

Function Index

build/1Build a URI.
parse/1Parse a URI.
parse/2Parse a URI, returning the result as either a uri() or url().
percent_decode/1Decode a percent encoded string value.
percent_encode/1Percent encode a string value.
percent_encode/2Percent encode a string value.
plus_decode/1Decode a percent encoded string value that uses pluses for spaces.
plus_encode/1Percent encode a string value similar to encode/1, but encodes spaces with a plus (+) instead of %20.
plus_encode/2Percent encode a string value similar to encode/1, but encodes spaces with a plus (+) instead of %20.

Function Details

build/1

build(Value :: uri() | url()) -> string()

Build a URI

parse/1

parse(Value :: string()) -> uri() | {error, Reason :: term()}

Parse a URI

Returns either the URI or an error term.

parse/2

parse(Value :: string(), Return :: uri | url) ->
         uri() | {error, Reason :: term()}

Parse a URI, returning the result as either a uri() or url().

On error, return an error term.

percent_decode/1

percent_decode(Value :: string()) -> string()

Decode a percent encoded string value.

percent_encode/1

percent_encode(Value :: string()) -> string()

Percent encode a string value. Note that this will return hexidecimal values in lowercase. If you need uppercase values, invoke percent_encode/2 with the second parameter as the value upercase.

percent_encode/2

percent_encode(Value :: string(), X2 :: hexcase()) -> string()

Percent encode a string value.

When lowercase is passed, hexidecimal strings with A-F values in them are returned as lowercase. Likewise, the uppercase value will encode hexidecimal strings as uppercase values.

plus_decode/1

plus_decode(Value :: string()) -> string()

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.

plus_encode/1

plus_encode(Value :: string()) -> string()

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.

plus_encode/2

plus_encode(Value :: string(), X2 :: hexcase()) -> string()

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. When lowercase is passed, hexidecimal strings with A-F values in them are returned as lowercase. Likewise, the uppercase value will encode hexidecimal strings as uppercase values.

Note: The use of plus for space is defined in RFC-1630 but does not appear in RFC-3986.


Generated by EDoc