mirror of
https://github.com/axios/axios.git
synced 2026-04-11 14:21:59 +08:00
Fixed query params composing; (#5018)
* Fixes #4999; * Added regression test;
This commit is contained in:
parent
d61dbede95
commit
3e4d52171e
@ -301,9 +301,14 @@ export default function httpAdapter(config) {
|
||||
|
||||
auth && headers.delete('authorization');
|
||||
|
||||
const path = parsed.pathname.concat(parsed.searchParams);
|
||||
let path;
|
||||
|
||||
try {
|
||||
buildURL(path, config.params, config.paramsSerializer).replace(/^\?/, '');
|
||||
path = buildURL(
|
||||
parsed.pathname + parsed.search,
|
||||
config.params,
|
||||
config.paramsSerializer
|
||||
).replace(/^\?/, '');
|
||||
} catch (err) {
|
||||
const customErr = new Error(err.message);
|
||||
customErr.config = config;
|
||||
@ -315,7 +320,7 @@ export default function httpAdapter(config) {
|
||||
headers.set('Accept-Encoding', 'gzip, deflate, br', false);
|
||||
|
||||
const options = {
|
||||
path: buildURL(path, config.params, config.paramsSerializer).replace(/^\?/, ''),
|
||||
path,
|
||||
method: method,
|
||||
headers: headers.toJSON(),
|
||||
agents: { http: config.httpAgent, https: config.httpsAgent },
|
||||
|
||||
13
test/unit/regression/bugs.js
Normal file
13
test/unit/regression/bugs.js
Normal file
@ -0,0 +1,13 @@
|
||||
import assert from 'assert';
|
||||
import axios from '../../../index.js';
|
||||
|
||||
describe('issues', function () {
|
||||
describe('4999', function () {
|
||||
it('should not fail with query parsing', async function () {
|
||||
const {data} = await axios.get('https://postman-echo.com/get?foo1=bar1&foo2=bar2');
|
||||
|
||||
assert.strictEqual(data.args.foo1, 'bar1');
|
||||
assert.strictEqual(data.args.foo2, 'bar2');
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user