mirror of
https://github.com/tenrok/axios.git
synced 2026-06-11 18:02:32 +03:00
Fixed missed minified builds; (#4805)
* Fixed missed minified builds; Refactored utils.js; Refactored `utils.isStandardBrowserEnv()` as a `platform/browser` property; Added builds size log; * Replaced `rollup-plugin-filesize` with `rollup-plugin-bundle-size`; Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
@@ -1,6 +1,36 @@
|
||||
import URLSearchParams from './classes/URLSearchParams.js'
|
||||
import FormData from './classes/FormData.js'
|
||||
|
||||
/**
|
||||
* Determine if we're running in a standard browser environment
|
||||
*
|
||||
* This allows axios to run in a web worker, and react-native.
|
||||
* Both environments support XMLHttpRequest, but not fully standard globals.
|
||||
*
|
||||
* web workers:
|
||||
* typeof window -> undefined
|
||||
* typeof document -> undefined
|
||||
*
|
||||
* react-native:
|
||||
* navigator.product -> 'ReactNative'
|
||||
* nativescript
|
||||
* navigator.product -> 'NativeScript' or 'NS'
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const isStandardBrowserEnv = (() => {
|
||||
let product;
|
||||
if (typeof navigator !== 'undefined' && (
|
||||
(product = navigator.product) === 'ReactNative' ||
|
||||
product === 'NativeScript' ||
|
||||
product === 'NS')
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
||||
})();
|
||||
|
||||
export default {
|
||||
isBrowser: true,
|
||||
classes: {
|
||||
@@ -8,5 +38,6 @@ export default {
|
||||
FormData,
|
||||
Blob
|
||||
},
|
||||
isStandardBrowserEnv,
|
||||
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user