Functions for working with URLs

**Configuration example**

```
<!-- <top_level_domains_path>/var/lib/clickhouse/top_level_domains/</top_level_domains_path> -->
<top_level_domains_lists>
    <!-- https://publicsuffix.org/list/public_suffix_list.dat -->
    <public_suffix_list>public_suffix_list.dat</public_suffix_list>
    <!-- NOTE: path is under top_level_domains_path -->
</top_level_domains_lists>
    

**Syntax**

```sql
cutToFirstSignificantSubdomainCustomWithWWW(url, tld_list_name)
```

**Arguments**

- `url` — URL or domain string to process. - `tld_list_name` — Name of the custom TLD list configured in ClickHouse.

**Returned value**

Part of the domain that includes top-level subdomains up to the first significant subdomain without stripping 'www'. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT cutToFirstSignificantSubdomainCustomWithWWW('www.foo', 'public_suffix_list');
```

```
┌─cutToFirstSignificantSubdomainCustomWithWWW('www.foo', 'public_suffix_list')─┐
│ www.foo                                                                      │
└──────────────────────────────────────────────────────────────────────────────┘
```

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

Introduced in: v22.10.0

Returns the part of the domain that includes top-level subdomains up to the first significant subdomain without stripping `www`.
Accepts custom TLD list name.
It can be useful if you need a fresh TLD list or if you have a custom list.
Similar to [cutToFirstSignificantSubdomainCustomWithWWW](#cutToFirstSignificantSubdomainCustomWithWWW) but conforms to [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986).

**Configuration example**

```
<!-- <top_level_domains_path>/var/lib/clickhouse/top_level_domains/</top_level_domains_path> -->
<top_level_domains_lists>
    <!-- https://publicsuffix.org/list/public_suffix_list.dat -->
    <public_suffix_list>public_suffix_list.dat</public_suffix_list>
    <!-- NOTE: path is under top_level_domains_path -->
</top_level_domains_lists>
    

**Syntax**

```sql
cutToFirstSignificantSubdomainCustomWithWWWRFC(url, tld_list_name)
```

**Arguments**

- `url` — URL or domain string to process according to RFC 3986. - `tld_list_name` — Name of the custom TLD list configured in ClickHouse.

**Returned value**

Returns the part of the domain that includes top-level subdomains up to the first significant subdomain without stripping `www`. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**RFC 3986 parsing preserving www with custom TLD list**

```
SELECT cutToFirstSignificantSubdomainCustomWithWWWRFC('https://www.subdomain.example.custom', 'public_suffix_list')
```

```
www.example.custom
```

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

Introduced in: v22.10.0

Returns the part of the domain that includes top-level subdomains up to the ["first significant subdomain"](/docs/sql-reference/functions/url-functions#firstSignificantSubdomain). Similar to [`cutToFirstSignificantSubdomain`](#cutToFirstSignificantSubdomain) but conforms to [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986).

**Syntax**

```
cutToFirstSignificantSubdomainRFC(url)
```

**Arguments**

- `url` — URL or domain string to process according to RFC 3986. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns the part of the domain that includes top-level subdomains up to the first significant subdomain if possible, otherwise returns an empty string. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT
    cutToFirstSignificantSubdomain('http://user:[email protected]:8080'),
    cutToFirstSignificantSubdomainRFC('http://user:[email protected]:8080');
```

```
┌─cutToFirstSignificantSubdomain('http://user:[email protected]:8080')─┬─cutToFirstSignificantSubdomainRFC('http://user:[email protected]:8080')─┐
│                                                                         │ example.com                                                                │
└─────────────────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────────────────────┘
```

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

Introduced in: v20.12.0

Returns the part of the domain that includes top-level subdomains up to the "first significant subdomain", without stripping '[www](http://www).'.

Similar to [`cutToFirstSignificantSubdomain`](#cutToFirstSignificantSubdomain) but preserves the '[www](http://www).' prefix if present.

**Syntax**

```
cutToFirstSignificantSubdomainWithWWW(url)
```

**Arguments**

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

**Returned value**

Returns the part of the domain that includes top-level subdomains up to the first significant subdomain (with www) if possible, otherwise returns an empty string. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT
    cutToFirstSignificantSubdomainWithWWW('https://news.clickhouse.com.tr/'),
    cutToFirstSignificantSubdomainWithWWW('www.tr'),
    cutToFirstSignificantSubdomainWithWWW('tr');
```

```
┌─cutToFirstSignificantSubdomainWithWWW('https://news.clickhouse.com.tr/')─┬─cutToFirstSignificantSubdomainWithWWW('www.tr')─┬─cutToFirstSignificantSubdomainWithWWW('tr')─┐
│ clickhouse.com.tr                                                        │ www.tr                                          │                                             │
└──────────────────────────────────────────────────────────────────────────┴─────────────────────────────────────────────────┴─────────────────────────────────────────────┘
```

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

Introduced in: v22.10.0

Returns the part of the domain that includes top-level subdomains up to the "first significant subdomain", without stripping 'www'. Similar to [`cutToFirstSignificantSubdomainWithWWW`](#cutToFirstSignificantSubdomainWithWWW) but conforms to [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986).

**Syntax**

```
cutToFirstSignificantSubdomainWithWWWRFC(url)
```

**Arguments**

- `url` — URL or domain string to process according to RFC 3986.

**Returned value**

Returns the part of the domain that includes top-level subdomains up to the first significant subdomain (with 'www') if possible, otherwise returns an empty string [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT
    cutToFirstSignificantSubdomainWithWWW('http:%2F%[email protected]/economicheskiy'),
    cutToFirstSignificantSubdomainWithWWWRFC('http:%2F%[email protected]/economicheskiy');
```

```
┌─cutToFirstSignificantSubdomainWithWWW('http:%2F%[email protected]/economicheskiy')─┬─cutToFirstSignificantSubdomainWithWWWRFC('http:%2F%[email protected]/economicheskiy')─┐
│                                                                                       │ mail.ru                                                                                  │
└───────────────────────────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────┘
```

## 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**