Merge pull request #1720 from bultkrantz/feature/custom-encoder · forwardemail/superagent@907d14b

Commit 907d14b

Merge pull request #1720 from bultkrantz/feature/custom-encoder

use custom encoder if it is sent in option object

File tree

1 file changed

lines changed

1 file changed

lines changed

Lines changed: 6 additions & 4 deletions

Original file line numberDiff line numberDiff line change

@@ -568,10 +568,12 @@ Request.prototype.auth = function (user, pass, options) {

568568

};

569569

}

570570
571-

const encoder = (string) => {

572-

if (typeof btoa === 'function') {

573-

return btoa(string);

574-

}

571+

const encoder =

572+

options.encoder ||

573+

(string) => {

574+

if (typeof btoa === 'function') {

575+

return btoa(string);

576+

}

575577
576578

throw new Error('Cannot use basic auth, btoa is not a function');

577579

};

0 commit comments