Skip to content

Commit

Permalink
use custom encoder if it is sent in option object
Browse files Browse the repository at this point in the history
  • Loading branch information
bultkrantz committed Apr 25, 2022
1 parent 508b9fb commit 04fc158
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/client.js
Expand Up @@ -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');
};
Expand Down

0 comments on commit 04fc158

Please sign in to comment.