From e4e32120cec8ba53fc1f69415d6a8ac10b9c9756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=98=A5=E6=97=AD?= <407466029@qq.com> Date: Wed, 31 May 2017 22:53:11 +0800 Subject: [PATCH] Convert the method parameter to lowercase --- lib/core/Axios.js | 1 + test/specs/requests.spec.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/core/Axios.js b/lib/core/Axios.js index 0eb4fecb41..57098533fd 100644 --- a/lib/core/Axios.js +++ b/lib/core/Axios.js @@ -35,6 +35,7 @@ Axios.prototype.request = function request(config) { } config = utils.merge(defaults, this.defaults, { method: 'get' }, config); + config.method = config.method.toLowerCase(); // Support baseURL config if (config.baseURL && !isAbsoluteURL(config.url)) { diff --git a/test/specs/requests.spec.js b/test/specs/requests.spec.js index ba7ffc606a..b42765882d 100644 --- a/test/specs/requests.spec.js +++ b/test/specs/requests.spec.js @@ -17,6 +17,22 @@ describe('requests', function () { }); }); + it('should treat method value as lowercase string', function (done) { + axios({ + url: '/foo', + method: 'POST' + }).then(function (response) { + expect(response.config.method).toBe('post'); + done(); + }); + + getAjaxRequest().then(function (request) { + request.respondWith({ + status: 200 + }); + }); + }); + it('should allow string arg as url, and config arg', function (done) { axios.post('/foo');