mirror of
https://github.com/tenrok/axios.git
synced 2026-06-23 20:40:40 +03:00
fix(adapter): fix undefined reference to hasBrowserEnv (#6572)
This commit is contained in:
@@ -229,7 +229,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|||||||
|
|
||||||
// Parse url
|
// Parse url
|
||||||
const fullPath = buildFullPath(config.baseURL, config.url);
|
const fullPath = buildFullPath(config.baseURL, config.url);
|
||||||
const parsed = new URL(fullPath, utils.hasBrowserEnv ? platform.origin : undefined);
|
const parsed = new URL(fullPath, platform.hasBrowserEnv ? platform.origin : undefined);
|
||||||
const protocol = parsed.protocol || supportedProtocols[0];
|
const protocol = parsed.protocol || supportedProtocols[0];
|
||||||
|
|
||||||
if (protocol === 'data:') {
|
if (protocol === 'data:') {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
import axios from '../../../index.js';
|
import axios from '../../../index.js';
|
||||||
import http from 'http';
|
import http from 'http';
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import utils from '../../../lib/utils.js';
|
|
||||||
import platform from '../../../lib/platform/index.js';
|
import platform from '../../../lib/platform/index.js';
|
||||||
|
|
||||||
|
|
||||||
@@ -52,17 +51,18 @@ describe('Server-Side Request Forgery (SSRF)', () => {
|
|||||||
let hasBrowserEnv, origin;
|
let hasBrowserEnv, origin;
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
hasBrowserEnv = utils.hasBrowserEnv;
|
assert.ok(platform.hasBrowserEnv !== undefined);
|
||||||
|
hasBrowserEnv = platform.hasBrowserEnv;
|
||||||
origin = platform.origin;
|
origin = platform.origin;
|
||||||
utils.hasBrowserEnv = true;
|
platform.hasBrowserEnv = true;
|
||||||
platform.origin = 'http://localhost:' + String(GOOD_PORT);
|
platform.origin = 'http://localhost:' + String(GOOD_PORT);
|
||||||
});
|
});
|
||||||
after(() => {
|
after(() => {
|
||||||
utils.hasBrowserEnv = hasBrowserEnv;
|
platform.hasBrowserEnv = hasBrowserEnv;
|
||||||
platform.origin = origin;
|
platform.origin = origin;
|
||||||
});
|
});
|
||||||
it('should fetch in client-side mode', async () => {
|
it('should fetch in client-side mode', async () => {
|
||||||
utils.hasBrowserEnv = true;
|
platform.hasBrowserEnv = true;
|
||||||
const ssrfAxios = axios.create({
|
const ssrfAxios = axios.create({
|
||||||
baseURL: 'http://localhost:' + String(GOOD_PORT),
|
baseURL: 'http://localhost:' + String(GOOD_PORT),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user