From 8870860f9ae74adeb3cc0af48dc7e42b166fd7e2 Mon Sep 17 00:00:00 2001 From: bluelovers Date: Thu, 12 Aug 2021 13:30:37 +0800 Subject: [PATCH 1/2] feat: support empty `password` when set `auth` --- index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.js b/index.js index c6052d5..6f6bb96 100644 --- a/index.js +++ b/index.js @@ -459,6 +459,16 @@ function set(part, value, fn) { } break; + case 'auth': + var instruction = []; + if (value) { + instruction = value.split(':'); + } + url[part] = value; + url.username = instruction[0] || ''; + url.password = instruction[1] || ''; + break; + default: url[part] = value; } From 4305afb28a6d79c8664ec9d219c6c574209cb735 Mon Sep 17 00:00:00 2001 From: bluelovers Date: Thu, 12 Aug 2021 15:38:28 +0800 Subject: [PATCH 2/2] Update index.js Co-authored-by: Luigi Pinca --- index.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 6f6bb96..6c8e0d9 100644 --- a/index.js +++ b/index.js @@ -460,13 +460,10 @@ function set(part, value, fn) { break; case 'auth': - var instruction = []; - if (value) { - instruction = value.split(':'); - } + var splits = value.split(':'); + url.username = splits[0]; + url.password = splits.length === 2 ? splits[1] : ''; url[part] = value; - url.username = instruction[0] || ''; - url.password = instruction[1] || ''; break; default: