Functions for working with URLs

## cutURLParameter[​](#cutURLParameter "Direct link to cutURLParameter")

Introduced in: v1.1.0

Removes the `name` parameter from a URL, if present.
This function does not encode or decode characters in parameter names, e.g. `Client ID` and `Client%20ID` are treated as different parameter names.

**Syntax**

```
cutURLParameter(url, name)
```

**Arguments**

- `url` — URL. [`String`](/docs/sql-reference/data-types/string)
- `name` — Name of URL parameter. [`String`](/docs/sql-reference/data-types/string) or [`Array(String)`](/docs/sql-reference/data-types/array)

**Returned value**

URL with `name` URL parameter removed. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT
    cutURLParameter('http://bigmir.net/?a=b&c=d&e=f#g', 'a') AS url_without_a,
    cutURLParameter('http://bigmir.net/?a=b&c=d&e=f#g', ['c', 'e']) AS url_without_c_and_e;
```

```
┌─url_without_a────────────────┬─url_without_c_and_e──────┐
│ http://bigmir.net/?c=d&e=f#g │ http://bigmir.net/?a=b#g │
└──────────────────────────────┴──────────────────────────┘
```

## cutWWW[​](#cutWWW "Direct link to cutWWW")

Introduced in: v1.1.0

Removes the leading `www.`, if present, from the URL's domain.

**Syntax**

```
cutWWW(url)
```

**Arguments**

- `url` — URL. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns the URL with leading `www.` removed from the domain. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT cutWWW('http://www.example.com/path?query=value#fragment');
```

```
┌─cutWWW('http://www.example.com/path?query=value#fragment')─┐
│ http://example.com/path?query=value#fragment               │
└────────────────────────────────────────────────────────────┘
```

## decodeURLComponent[​](#decodeURLComponent "Direct link to decodeURLComponent")

Introduced in: v1.1.0

Takes a URL-encoded string as input and decodes it back to its original, readable form.

**Syntax**

```
decodeURLComponent(url)
```

**Arguments**

- `url` — URL. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns the decoded URL. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT decodeURLComponent('http://127.0.0.1:8123/?query=SELECT%201%3B') AS DecodedURL;
```

```
┌─DecodedURL─────────────────────────────┐
│ http://127.0.0.1:8123/?query=SELECT 1; │
└────────────────────────────────────────┘
```

## decodeURLFormComponent[​](#decodeURLFormComponent "Direct link to decodeURLFormComponent")

Introduced in: v1.1.0

Decodes URL-encoded strings using form encoding rules ([RFC-1866](https://www.rfc-editor.org/rfc/rfc1866.html)), where `+` signs are converted to spaces and percent-encoded characters are decoded.

**Syntax**

```
decodeURLFormComponent(url)
```

**Arguments**

- `url` — URL. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns the decoded URL. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT decodeURLFormComponent('http://127.0.0.1:8123/?query=SELECT%201+2%2B3') AS DecodedURL;
```

```
┌─DecodedURL────────────────────────────────┐
│ http://127.0.0.1:8123/?query=SELECT 1 2+3 │
└───────────────────────────────────────────┘
```

## domain[​](#domain "Direct link to domain")

Introduced in: v1.1.0

Extracts the hostname from a URL.

The URL can be specified with or without a protocol.

**Syntax**

```
domain(url)
```

**Arguments**

- `url` — URL. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns the host name if the input string can be parsed as a URL, otherwise an empty string. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT domain('svn+ssh://some.svn-hosting.com:80/repo/trunk');
```

```
┌─domain('svn+ssh://some.svn-hosting.com:80/repo/trunk')─┐
│ some.svn-hosting.com                                   │
└────────────────────────────────────────────────────────┘
```

## domainRFC[​](#domainRFC "Direct link to domainRFC")

Introduced in: v22.10.0

Extracts the hostname from a URL.
Similar to [`domain`](#domain), but [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986) conformant.

**Syntax**

```
domainRFC(url)
```

**Arguments**

- `url` — URL. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns the host name if the input string can be parsed as a URL, otherwise an empty string. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT
    domain('http://user:[email protected]:8080/path?query=value#fragment'),
    domainRFC('http://user:[email protected]:8080/path?query=value#fragment');
```

```
┌─domain('http://user:[email protected]:8080/path?query=value#fragment')─┬─domainRFC('http://user:[email protected]:8080/path?query=value#fragment')─┐
│                                                                           │ example.com                                                                  │
└───────────────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────┘
```

## domainWithoutWWW[​](#domainWithoutWWW "Direct link to domainWithoutWWW")

Introduced in: v1.1.0

Returns the domain of a URL without leading `www.` if present.

**Syntax**

```
domainWithoutWWW(url)
```

**Arguments**

- `url` — URL. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns the domain name if the input string can be parsed as a URL (without leading `www.`), otherwise an empty string. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT domainWithoutWWW('http://[email protected]:80/');
```

```
┌─domainWithoutWWW('http://[email protected]:80/')─┐
│ example.com                                         │
└─────────────────────────────────────────────────────┘
```

## domainWithoutWWWRFC[​](#domainWithoutWWWRFC "Direct link to domainWithoutWWWRFC")

Introduced in: v1.1.0

Returns the domain without leading `www.` if present. Similar to [`domainWithoutWWW`](#domainWithoutWWW) but conforms to [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986).

**Syntax**

```
domainWithoutWWWRFC(url)
```

**Arguments**

- `url` — URL. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns the domain name if the input string can be parsed as a URL (without leading `www.`), otherwise an empty string. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT
    domainWithoutWWW('http://user:[email protected]:8080/path?query=value#fragment'),
    domainWithoutWWWRFC('http://user:[email protected]:8080/path?query=value#fragment');
```

```
┌─domainWithoutWWW('http://user:[email protected]:8080/path?query=value#fragment')─┬─domainWithoutWWWRFC('http://user:[email protected]:8080/path?query=value#fragment')─┐
│                                                                                         │ example.com                                                                                │
└─────────────────────────────────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────────────────────────────────────┘
```

## encodeURLComponent[​](#encodeURLComponent "Direct link to encodeURLComponent")

Introduced in: v22.3.0

Takes a regular string and converts it into a URL-encoded (percent-encoded) format where special characters are replaced with their percent-encoded equivalents.

**Syntax**

```
encodeURLComponent(url)
```

**Arguments**

- `url` — URL. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns the encoded URL. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT encodeURLComponent('http://127.0.0.1:8123/?query=SELECT 1;') AS EncodedURL;
```

```
┌─EncodedURL───────────────────────────────────────────────┐
│ http%3A%2F%2F127.0.0.1%3A8123%2F%3Fquery%3DSELECT%201%3B │
└──────────────────────────────────────────────────────────┘
```