Skip to content

Commit

Permalink
Merge pull request #1720 from bultkrantz/feature/custom-encoder
Browse files Browse the repository at this point in the history
use custom encoder if it is sent in option object
  • Loading branch information
titanism authored Apr 26, 2022
2 parents 508b9fb + 04fc158 commit 907d14b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/client.js
Original file line number Diff line number Diff line change
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 907d14b

Please sign in to comment.