@@ -2,63 +2,12 @@ import URLSearchParams from './classes/URLSearchParams.js'
22import FormData from './classes/FormData.js'
33import Blob from './classes/Blob.js'
44
5- /**
6- * Determine if we're running in a standard browser environment
7- *
8- * This allows axios to run in a web worker, and react-native.
9- * Both environments support XMLHttpRequest, but not fully standard globals.
10- *
11- * web workers:
12- * typeof window -> undefined
13- * typeof document -> undefined
14- *
15- * react-native:
16- * navigator.product -> 'ReactNative'
17- * nativescript
18- * navigator.product -> 'NativeScript' or 'NS'
19- *
20- * @returns {boolean }
21- */
22- const isStandardBrowserEnv = ( ( ) => {
23- let product ;
24- if ( typeof navigator !== 'undefined' && (
25- ( product = navigator . product ) === 'ReactNative' ||
26- product === 'NativeScript' ||
27- product === 'NS' )
28- ) {
29- return false ;
30- }
31-
32- return typeof window !== 'undefined' && typeof document !== 'undefined' ;
33- } ) ( ) ;
34-
35- /**
36- * Determine if we're running in a standard browser webWorker environment
37- *
38- * Although the `isStandardBrowserEnv` method indicates that
39- * `allows axios to run in a web worker`, the WebWorker will still be
40- * filtered out due to its judgment standard
41- * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
42- * This leads to a problem when axios post `FormData` in webWorker
43- */
44- const isStandardBrowserWebWorkerEnv = ( ( ) => {
45- return (
46- typeof WorkerGlobalScope !== 'undefined' &&
47- // eslint-disable-next-line no-undef
48- self instanceof WorkerGlobalScope &&
49- typeof self . importScripts === 'function'
50- ) ;
51- } ) ( ) ;
52-
53-
545export default {
556 isBrowser : true ,
567 classes : {
578 URLSearchParams,
589 FormData,
5910 Blob
6011 } ,
61- isStandardBrowserEnv,
62- isStandardBrowserWebWorkerEnv,
6312 protocols : [ 'http' , 'https' , 'file' , 'blob' , 'url' , 'data' ]
6413} ;
0 commit comments