Skip to content

Commit 7004707

Browse files
authored
fix(adapter): fix undefined reference to hasBrowserEnv (#6572)
1 parent fed1a4b commit 7004707

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

lib/adapters/http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
229229

230230
// Parse url
231231
const fullPath = buildFullPath(config.baseURL, config.url);
232-
const parsed = new URL(fullPath, utils.hasBrowserEnv ? platform.origin : undefined);
232+
const parsed = new URL(fullPath, platform.hasBrowserEnv ? platform.origin : undefined);
233233
const protocol = parsed.protocol || supportedProtocols[0];
234234

235235
if (protocol === 'data:') {

test/unit/regression/SNYK-JS-AXIOS-7361793.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import axios from '../../../index.js';
55
import http from 'http';
66
import assert from 'assert';
7-
import utils from '../../../lib/utils.js';
87
import platform from '../../../lib/platform/index.js';
98

109

@@ -52,17 +51,18 @@ describe('Server-Side Request Forgery (SSRF)', () => {
5251
let hasBrowserEnv, origin;
5352

5453
before(() => {
55-
hasBrowserEnv = utils.hasBrowserEnv;
54+
assert.ok(platform.hasBrowserEnv !== undefined);
55+
hasBrowserEnv = platform.hasBrowserEnv;
5656
origin = platform.origin;
57-
utils.hasBrowserEnv = true;
57+
platform.hasBrowserEnv = true;
5858
platform.origin = 'http://localhost:' + String(GOOD_PORT);
5959
});
6060
after(() => {
61-
utils.hasBrowserEnv = hasBrowserEnv;
61+
platform.hasBrowserEnv = hasBrowserEnv;
6262
platform.origin = origin;
6363
});
6464
it('should fetch in client-side mode', async () => {
65-
utils.hasBrowserEnv = true;
65+
platform.hasBrowserEnv = true;
6666
const ssrfAxios = axios.create({
6767
baseURL: 'http://localhost:' + String(GOOD_PORT),
6868
});

0 commit comments

Comments
 (0)