Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed missed minified builds; #4805

Merged
merged 3 commits into from Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/adapters/xhr.js
Expand Up @@ -58,7 +58,7 @@ export default function xhrAdapter(config) {
}
}

if (utils.isFormData(requestData) && utils.isStandardBrowserEnv()) {
if (utils.isFormData(requestData) && platform.isStandardBrowserEnv) {
requestHeaders.setContentType(false); // Let the browser set it
}

Expand Down Expand Up @@ -174,7 +174,7 @@ export default function xhrAdapter(config) {
// Add xsrf header
// This is only done if running in a standard browser environment.
// Specifically not if we're in a web worker, or react-native.
if (utils.isStandardBrowserEnv()) {
if (platform.isStandardBrowserEnv) {
// Add xsrf header
const xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath))
&& config.xsrfCookieName && cookies.read(config.xsrfCookieName);
Expand Down
3 changes: 2 additions & 1 deletion lib/helpers/cookies.js
@@ -1,8 +1,9 @@
'use strict';

import utils from './../utils.js';
import platform from '../platform/index.js';

export default utils.isStandardBrowserEnv() ?
export default platform.isStandardBrowserEnv ?

// Standard browser envs support document.cookie
(function standardBrowserEnv() {
Expand Down
3 changes: 2 additions & 1 deletion lib/helpers/isURLSameOrigin.js
@@ -1,8 +1,9 @@
'use strict';

import utils from './../utils.js';
import platform from '../platform/index.js';

export default utils.isStandardBrowserEnv() ?
export default platform.isStandardBrowserEnv ?

// Standard browser envs have full support of the APIs needed to test
// whether the request URL is of the same origin as current location.
Expand Down
31 changes: 31 additions & 0 deletions lib/platform/browser/index.js
@@ -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', 'data']
};