Skip to content

Commit

Permalink
Axios create url bug (axios#2290)
Browse files Browse the repository at this point in the history
* Fix axios#2234 

* added spacing --eslint

* added test cases

* removed unexpected cases after updating the code
  • Loading branch information
dhrubesh authored and genie-youn committed Sep 27, 2019
1 parent 0f96f73 commit 1cc39f5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/core/mergeConfig.js
Expand Up @@ -34,7 +34,7 @@ module.exports = function mergeConfig(config1, config2) {
});

utils.forEach([
'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
'baseURL', 'url', 'transformRequest', 'transformResponse', 'paramsSerializer',
'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'maxContentLength',
'validateStatus', 'maxRedirects', 'httpAgent', 'httpsAgent', 'cancelToken',
Expand Down
2 changes: 0 additions & 2 deletions test/specs/core/mergeConfig.spec.js
Expand Up @@ -32,13 +32,11 @@ describe('core::mergeConfig', function() {

it('should not inherit request options', function() {
var localDefaults = {
url: '__sample url__',
method: '__sample method__',
params: '__sample params__',
data: { foo: true }
};
var merged = mergeConfig(localDefaults, {});
expect(merged.url).toEqual(undefined);
expect(merged.method).toEqual(undefined);
expect(merged.params).toEqual(undefined);
expect(merged.data).toEqual(undefined);
Expand Down
13 changes: 13 additions & 0 deletions test/specs/instance.spec.js
Expand Up @@ -37,6 +37,19 @@ describe('instance', function () {
});
});

it('should make an http request with url instead of baseURL', function () {
var instance = axios.create({
url: 'https://api.example.com'
});

instance('/foo');

getAjaxRequest().then(function (request) {
expect(request.url).toBe('/foo');
done();
});
});

it('should make an http request', function (done) {
var instance = axios.create();

Expand Down

0 comments on commit 1cc39f5

Please sign in to comment.