URI Utilities
URI Utilities
Parse, construct, and manipulate URIs and URLs:
Functions
sandman.uri.parse()- Parses a URI string into componentssandman.uri.tostring()- Converts URI components to a stringsandman.uri.encode()- URI-encodes a urlsandman.uri.decode()- URI-decodes a URIsandman.uri.encode_component()- URI-encodes a URI componentsandman.uri.decode_component()- URI-decodes a URI component
sandman.uri.parse
Type: Function
Description: Parses a URI string into components
Usage
components = sandman.uri.parse("https://user@server.com:1234/test/path?qry=1¶m=2")
Parameters
- uri: string
Returns
- components: table
Examples
-- Basic usage
components = sandman.uri.parse("https://user@server.com:1234/test/path?qry=1¶m=2")
sandman.uri.tostring
Type: Function
Description: Converts URI components to a string
Usage
uri = sandman.uri.tostring({host = "server.com", path = "/test/path", port = 1234, query = {qry = 1, param = 2}, scheme = "https", userinfo = "user"})
Parameters
- components: table
Returns
- uri: string
Examples
-- Basic usage
uri = sandman.uri.tostring({host = "server.com", path = "/test/path", port = 1234, query = {qry = 1, param = 2}, scheme = "https", userinfo = "user"})
sandman.uri.encode
Type: Function
Description: URI-encodes a url
Usage
encoded_uri = sandman.uri.encode("http://test.com/Hello Sandman")
Parameters
- uri: string
Returns
- encoded_uri: string
Examples
-- Basic usage
encoded_uri = sandman.uri.encode("http://test.com/Hello Sandman")
sandman.uri.decode
Type: Function
Description: URI-decodes a URI
Usage
uri = sandman.uri.decode("http://test.com/Hello%20Sandman")
Parameters
- encoded_uri: string
Returns
- uri: string
Examples
-- Basic usage
uri = sandman.uri.decode("http://test.com/Hello%20Sandman")
sandman.uri.encode_component
Type: Function
Description: URI-encodes a URI component
Usage
encoded_uri = sandman.uri.encode_component("http://test.com/Hello Sandman")
Parameters
- uri: string
Returns
- encoded_uri: string
Examples
-- Basic usage
encoded_uri = sandman.uri.encode_component("http://test.com/Hello Sandman")
sandman.uri.decode_component
Type: Function
Description: URI-decodes a URI component
Usage
uri = sandman.uri.decode_component("http%3A%2F%2Ftest.com%2FHello%20Sandman")
Parameters
- encoded_uri: string
Returns
- uri: string
Examples
-- Basic usage
uri = sandman.uri.decode_component("http%3A%2F%2Ftest.com%2FHello%20Sandman")