[@polka/url] Incorrect query params parsing when param contains encoded "&"
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 176
- PR merge metrics
- No merged PRs in 30d
Description
Consider the url below:
```
/?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DeVTXPUF4Oz4%26list%3DPLlqZM4covn1G3hqrvNwpRy19pGDTYkUK6"
```
`@polka/url` parse the above into:
```
{
url: 'https://www.youtube.com/watch?v=eVTXPUF4Oz4',
list: 'PLlqZM4covn1G3hqrvNwpRy19pGDTYkUK6'
}
```
which is incorrect.
## Reproduction
```js
const parser = require("@polka/url");
const querystring = require("querystring");
const url = `/?url=${encodeURIComponent(
"https://www.youtube.com/watch?v=eVTXPUF4Oz4&list=PLlqZM4covn1G3hqrvNwpRy19pGDTYkUK6"
)}`;
console.log(parser({ url }, true)?.query);
// {
// url: 'https://www.youtube.com/watch?v=eVTXPUF4Oz4',
// list: 'PLlqZM4covn1G3hqrvNwpRy19pGDTYkUK6'
// }
const queryparamsstr = url.substring(url.indexOf("?") + 1);
console.log(querystring.parse(queryparamsstr));
// [Object: null prototype] {
// url: 'https://www.youtube.com/watch?v=eVTXPUF4Oz4&list=PLlqZM4covn1G3hqrvNwpRy19pGDTYkUK'
// }
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the @polka/url parser shown in the reproduction and run the provided JavaScript case alongside querystring.parse for comparison. The issue is done when an encoded ampersand remains part of the url parameter value instead of creating a separate list parameter.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100