Skip to content

URI

URI Parsing

omni_web provides API for parsing URIs (omni_web.text_to_uri) that is also available through by casting text to omni_web.uri.

           select *
           from
               omni_web.text_to_uri('http://foo:bar@example.com:8080/path/to/page?query#frag');

results in

Column Value
scheme http
user_info foo:bar
host example.com
path path/to/page
port 8080
query query
fragment frag

URL/URI Encoding

Functionality for URL encoding

String encoding for a URL

To encode a string to be safely included as part of a URL:

select omni_web.url_encode('Hello World')

You will get Hello%20World

To decode and get back to the original string:

select omni_web.url_encode('Hello%20World')

Encoding a URI

Similar to JavaScript's encodeUri/decodeUri, you can also encode/decode a URI without encoding the "unreserved marks":

select omni_web.uri_encode('http://hu.wikipedia.org/wiki/São_Paulo')

The above results in http://hu.wikipedia.org/wiki/S%C3%A3o_Paulo

A counterpart function to that is uri_decode.