Skip to content

Commit

Permalink
renaming xsrf to xsrfEnabled and defaulting to true
Browse files Browse the repository at this point in the history
  • Loading branch information
skevy committed Sep 2, 2015
1 parent c44f6a7 commit 7e2d6f7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion axios.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ declare module axios {
data?: any;
withCredentials?: boolean;
responseType?: string;
xsrf?: boolean;
xsrfEnabled?: boolean;
xsrfCookieName?: string;
xsrfHeaderName?: string;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/adapters/xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion lib/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions test/specs/xsrf.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ describe('xsrf', function () {
var request;

axios({
url: '/foo',
xsrf: true
url: '/foo'
});

setTimeout(function () {
Expand All @@ -31,8 +30,7 @@ describe('xsrf', function () {
document.cookie = axios.defaults.xsrfCookieName + '=12345';

axios({
url: '/foo',
xsrf: true
url: '/foo'
});

setTimeout(function () {
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});

0 comments on commit 7e2d6f7

Please sign in to comment.