fix(mixins/_parseBasicAuth): consider empty password as missing

This makes `username:` recognized as token, just like `username` is.

This fixes token-based authentication in HttpProxy with cURL.
This commit is contained in:
Julien Fontanet 2022-10-20 10:21:09 +02:00
parent 3bad40095a
commit 389a765825

View File

@ -15,6 +15,8 @@ export function parseBasicAuth(header) {
const i = credentials.indexOf(':')
if (i === -1) {
credentials = { token: credentials }
} else if (i === credentials.length - 1) {
credentials = { token: credentials.slice(0, i) }
} else {
// https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.1
credentials = {