ClickHouse / ClickHouse/ClickHouse
Possible bug in cutQueryStringAndFragment
- Dominant language
- C++
- Stars
- 49.9k
- Forks
- 9k
- Avg merge
- 21h 32m
- Merged PRs (30d)
- 515
Description
**Describe the unexpected behaviour**
I need to cut unwanted parts of urls that's passed from different clients (I can't control URL format), so I use cutQueryStringAndFragment function. It is works well, but sometimes there is an unexpected behavior described bellow. Is it bug or not? I understand what it is not matches URL specification, but in real life there is many URLs like this.
I asked this because processing this URLs works well in Javascript for my case.
```
> new URL('https://www.example.com/index.html#a=1?b=2')
URL {
href: 'https://www.example.com/index.html#a=1?b=2',
origin: 'https://www.example.com',
protocol: 'https:',
username: '',
password: '',
host: 'www.example.com',
hostname: 'www.example.com',
port: '',
pathname: '/index.html',
search: '',
searchParams: URLSearchParams {},
hash: '#a=1?b=2'
}
```
**How to reproduce**
* Which ClickHouse server version to use
22.8.11.15
* Queries to run that lead to unexpected result
```
SELECT cutQueryStringAndFragment('https://www.example.com/index.html#a=1?b=2')
Query id: 67bcc124-b5e0-449e-8ef1-91f14698845f
┌─cutQueryStringAndFragment('https://www.example.com/index.html#a=1?b=2')─┐
│ https://www.example.com/index.html#a=1 │
└─────────────────────────────────────────────────────────────────────────┘
```
**Expected behavior**
```https://www.example.com/index.html``` - URL without any hashes or query params.
Contributor guide
Assessment
This issue has not been assessed yet.