From 04fc158c418477dc34a3b799e80d6ddd34385a67 Mon Sep 17 00:00:00 2001 From: Marcus Hultkrantz Date: Mon, 25 Apr 2022 10:34:26 +0200 Subject: [PATCH] use custom encoder if it is sent in option object --- src/client.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/client.js b/src/client.js index 444fe1e48..6bcae71ea 100644 --- a/src/client.js +++ b/src/client.js @@ -568,10 +568,12 @@ Request.prototype.auth = function (user, pass, options) { }; } - const encoder = (string) => { - if (typeof btoa === 'function') { - return btoa(string); - } + const encoder = + options.encoder || + (string) => { + if (typeof btoa === 'function') { + return btoa(string); + } throw new Error('Cannot use basic auth, btoa is not a function'); };