feat(browser): make script-tag friendly
This commit is contained in:
parent
91977b84e3
commit
fd6ed8722e
10
urequest.js
10
urequest.js
|
@ -1,3 +1,4 @@
|
|||
(function (exports) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
|
@ -80,9 +81,13 @@ function setDefaults(_defs) {
|
|||
if ('string' !== typeof opts.auth) {
|
||||
let u = opts.auth.user || opts.auth.username || '';
|
||||
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) {
|
||||
reqOpts.headers.Authorization = encodeBasicAuth(`${opts.auth}`);
|
||||
reqOpts.headers.Authorization = encodeBasicAuth(
|
||||
`${opts.auth}`
|
||||
);
|
||||
}
|
||||
|
||||
// [request-compat]
|
||||
|
@ -221,3 +226,4 @@ if ('undefined' !== typeof module) {
|
|||
module.exports = defaultRequest;
|
||||
module.exports.defaults = setDefaults;
|
||||
}
|
||||
})(('undefined' !== typeof module && module.exports) || window);
|
||||
|
|
Loading…
Reference in New Issue