6.18. URL Functions
Extraction Functions
The URL extraction functions extract components from HTTP URLs(or any valid URIs conforming to RFC 2396).The following syntax is supported:
- [protocol:][//host[:port]][path][?query][#fragment]
The extracted components do not contain URI syntax separatorssuch as :
or ?
.
urlextract_fragment
(_url) → varchar
Returns the fragment identifier fromurl
.
urlextract_host
(_url) → varchar
Returns the host fromurl
.
urlextract_parameter
(_url, name) → varchar
Returns the value of the first query string parameter namedname
fromurl
. Parameter extraction is handled in the typical manneras specified by RFC 1866#section-8.2.1.
urlextract_path
(_url) → varchar
Returns the path fromurl
.
urlextract_port
(_url) → bigint
Returns the port number fromurl
.
urlextract_protocol
(_url) → varchar
Returns the protocol fromurl
.
urlextract_query
(_url) → varchar
Returns the query string fromurl
.
Encoding Functions
urlencode
(_value) → varchar
Escapesvalue
by encoding it so that it can be safely included inURL query parameter names and values:
- Alphanumeric characters are not encoded.
- The characters ., -, * and are not encoded.
- The ASCII space character is encoded as +.
- All other characters are converted to UTF-8 and the bytes are encodedas the string %XX where XX is the uppercase hexadecimalvalue of the UTF-8 byte.
url_decode
(_value) → varchar
Unescapes the URL encodedvalue
.This function is the inverse ofurl_encode()
.