feat(browser): make script-tag friendly

This commit is contained in:
AJ ONeal 2022-09-28 23:05:09 -06:00
parent 91977b84e3
commit fd6ed8722e
Signed by: coolaj86
GPG Key ID: 585419CA6DB0AA23
1 changed files with 200 additions and 194 deletions

View File

@ -1,3 +1,4 @@
(function (exports) {
'use strict'; 'use strict';
/** /**
@ -80,9 +81,13 @@ function setDefaults(_defs) {
if ('string' !== typeof opts.auth) { if ('string' !== typeof opts.auth) {
let u = opts.auth.user || opts.auth.username || ''; let u = opts.auth.user || opts.auth.username || '';
let p = opts.auth.pass || opts.auth.password || ''; let p = opts.auth.pass || opts.auth.password || '';
reqOpts.headers.Authorization = encodeBasicAuth(`${u}:${p}`); reqOpts.headers.Authorization = encodeBasicAuth(
`${u}:${p}`
);
} else if ('string' === typeof opts.auth) { } else if ('string' === typeof opts.auth) {
reqOpts.headers.Authorization = encodeBasicAuth(`${opts.auth}`); reqOpts.headers.Authorization = encodeBasicAuth(
`${opts.auth}`
);
} }
// [request-compat] // [request-compat]
@ -221,3 +226,4 @@ if ('undefined' !== typeof module) {
module.exports = defaultRequest; module.exports = defaultRequest;
module.exports.defaults = setDefaults; module.exports.defaults = setDefaults;
} }
})(('undefined' !== typeof module && module.exports) || window);