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:

  1. [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 from url.
urlextract_host(_url) → varchar

Returns the host from url.
urlextract_parameter(_url, name) → varchar

Returns the value of the first query string parameter named namefrom url. Parameter extraction is handled in the typical manneras specified by RFC 1866#section-8.2.1.
urlextract_path(_url) → varchar

Returns the path from url.
urlextract_port(_url) → bigint

Returns the port number from url.
urlextract_protocol(_url) → varchar

Returns the protocol from url.
urlextract_query(_url) → varchar

Returns the query string from url.

Encoding Functions

urlencode(_value) → varchar

Escapes value 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 encoded value.This function is the inverse of url_encode().

原文: https://prestodb.io/docs/current/functions/url.html