Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored utils.js; Refactored `utils.isStandardBrowserEnv()` as a `platform/browser` property; Added builds size log;
- Loading branch information
1 parent
bdf493c
commit df891dc
Showing
8 changed files
with
1,726 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,43 @@ | ||
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: { | ||
URLSearchParams, | ||
FormData, | ||
Blob | ||
}, | ||
isStandardBrowserEnv, | ||
protocols: ['http', 'https', 'file', 'blob', 'url'] | ||
}; |
Oops, something went wrong.