From 7e2d6f7c1f0545a2711dc83860267efb7ec3e59a Mon Sep 17 00:00:00 2001 From: Adam Miskiewicz Date: Wed, 2 Sep 2015 11:39:13 -0400 Subject: [PATCH] renaming `xsrf` to `xsrfEnabled` and defaulting to true --- README.md | 4 ++-- axios.d.ts | 2 +- lib/adapters/xhr.js | 2 +- lib/axios.js | 2 +- test/specs/xsrf.spec.js | 6 ++---- test/typescript/axios.ts | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 96cd46bc08..922d6ea171 100644 --- a/README.md +++ b/README.md @@ -182,8 +182,8 @@ This is the available config options for making requests. Only the `url` is requ // options are 'arraybuffer', 'blob', 'document', 'json', 'text' responseType: 'json', // default - // `xsrf` indicates whether or not cross-site request forgery protection is enabled - xsrf: false, // default + // `xsrfEnabled` indicates whether or not cross-site request forgery protection is enabled + xsrfEnabled: true, // default // `xsrfCookieName` is the name of the cookie to use as a value for xsrf token. // used only when `xsrf` is true diff --git a/axios.d.ts b/axios.d.ts index 35e1eacc96..c4f0019fbe 100644 --- a/axios.d.ts +++ b/axios.d.ts @@ -39,7 +39,7 @@ declare module axios { data?: any; withCredentials?: boolean; responseType?: string; - xsrf?: boolean; + xsrfEnabled?: boolean; xsrfCookieName?: string; xsrfHeaderName?: string; } diff --git a/lib/adapters/xhr.js b/lib/adapters/xhr.js index 3487a0d0c7..b7def92a25 100644 --- a/lib/adapters/xhr.js +++ b/lib/adapters/xhr.js @@ -62,7 +62,7 @@ module.exports = function xhrAdapter(resolve, reject, config) { } }; - if (config.xsrf) { + if (config.xsrfEnabled) { var cookies = require('./../helpers/cookies'); var urlIsSameOrigin = require('./../helpers/urlIsSameOrigin'); diff --git a/lib/axios.js b/lib/axios.js index 93b216130a..e5403c9fb1 100644 --- a/lib/axios.js +++ b/lib/axios.js @@ -22,7 +22,7 @@ var axios = module.exports = function axios(config) { headers: {}, transformRequest: defaults.transformRequest, transformResponse: defaults.transformResponse, - xsrf: false + xsrfEnabled: true }, config); // Don't allow overriding defaults.withCredentials diff --git a/test/specs/xsrf.spec.js b/test/specs/xsrf.spec.js index 0a97b6c2af..518ae2594a 100644 --- a/test/specs/xsrf.spec.js +++ b/test/specs/xsrf.spec.js @@ -14,8 +14,7 @@ describe('xsrf', function () { var request; axios({ - url: '/foo', - xsrf: true + url: '/foo' }); setTimeout(function () { @@ -31,8 +30,7 @@ describe('xsrf', function () { document.cookie = axios.defaults.xsrfCookieName + '=12345'; axios({ - url: '/foo', - xsrf: true + url: '/foo' }); setTimeout(function () { diff --git a/test/typescript/axios.ts b/test/typescript/axios.ts index 8c1bc5506a..51a6b4f4bd 100644 --- a/test/typescript/axios.ts +++ b/test/typescript/axios.ts @@ -106,7 +106,7 @@ axios({ }, withCredentials: false, // default responseType: 'json', // default - xsrf: false, // default + xsrfEnabled: true, // default xsrfCookieName: 'XSRF-TOKEN', // default xsrfHeaderName: 'X-XSRF-TOKEN' // default });