GoogleChromeLabs / GoogleChromeLabs/native-url
Parsing of `auth` differs from Node's behaviour
- Dominant language
- JavaScript
- Stars
- 286
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
## Expected Behavior
When the username is empty and a password is available, the returned value of `auth` should align with output from Node's `url` module.
```js
const url = require('url');
const nativeUrl = require('native-url');
url.parse('http://:password@test.com');
// { auth: ':password', ... }
nativeUrl.parse('http://:password@test.com');
// { auth: ':password', ... }
```
## Actual Behavior
```js
const url = require('url');
const nativeUrl = require('native-url');
url.parse('http://:password@test.com');
// { auth: ':password', ... }
nativeUrl.parse('http://:password@test.com');
// { auth: 'password', ... }
```
## Steps to Reproduce the Problem
As described in code blocks above.
The culprit is this block, where all falsy values are filtered out.
https://github.com/GoogleChromeLabs/native-url/blob/0c5aec20a765bc6a396b6066abf6951dbb5d000d/src/parse.js#L188-L191
I do think that this should technically be non-compliant with the spec (HTTP Basic Auth requires username to be defined) though ... ?
## Specifications
- Version: 0.2.6
- Platform: macOS 10.15.5
Contributor guide
Assessment
This issue has not been assessed yet.