@servicetitan/ajax-handlers
Advanced tools
Comparing version 17.3.1 to 17.3.2
@@ -68,16 +68,15 @@ "use strict"; | ||
const absoluteUrlRegex = /^(?:[a-z]+:)?\/\//i; | ||
if (config.headers) { | ||
config.headers = { | ||
'Content-Type': 'application/json;charset=UTF-8', | ||
'Accept': 'application/json', | ||
}; | ||
if (config.url && !absoluteUrlRegex.test(config.url)) { | ||
config.headers['X-Requested-With'] = 'XMLHttpRequest'; | ||
const CSRFTokenName = 'X-CSRF-Token'; | ||
const token = js_cookie_1.default.get(CSRFTokenName); | ||
if (token) { | ||
config.headers[CSRFTokenName] = token; | ||
} | ||
const headers = { | ||
'Content-Type': 'application/json;charset=UTF-8', | ||
'Accept': 'application/json', | ||
}; | ||
if (config.url && !absoluteUrlRegex.test(config.url)) { | ||
headers['X-Requested-With'] = 'XMLHttpRequest'; | ||
const CSRFTokenName = 'X-CSRF-Token'; | ||
const token = js_cookie_1.default.get(CSRFTokenName); | ||
if (token) { | ||
headers[CSRFTokenName] = token; | ||
} | ||
} | ||
config.headers = Object.assign(Object.assign({}, headers), config.headers); | ||
return config; | ||
@@ -84,0 +83,0 @@ }); |
{ | ||
"name": "@servicetitan/ajax-handlers", | ||
"version": "17.3.1", | ||
"version": "17.3.2", | ||
"description": "", | ||
@@ -20,3 +20,3 @@ "repository": { | ||
"devDependencies": { | ||
"@servicetitan/react-ioc": "^17.3.1", | ||
"@servicetitan/react-ioc": "^17.3.2", | ||
"@types/jquery": "~2.0.57", | ||
@@ -40,3 +40,3 @@ "@types/js-cookie": "~3.0.0", | ||
}, | ||
"gitHead": "eabf6970049b576de537655f20f6be5c2fa33e4f" | ||
"gitHead": "6653b0dcb786d1e3958408e081bb2ea927140331" | ||
} |
@@ -1,2 +0,2 @@ | ||
import axios, { AxiosRequestTransformer } from 'axios'; | ||
import axios, { AxiosRequestTransformer, AxiosRequestHeaders } from 'axios'; | ||
import Cookies from 'js-cookie'; | ||
@@ -74,19 +74,19 @@ | ||
if (config.headers) { | ||
config.headers = { | ||
'Content-Type': 'application/json;charset=UTF-8', | ||
'Accept': 'application/json', | ||
}; | ||
const headers: AxiosRequestHeaders = { | ||
'Content-Type': 'application/json;charset=UTF-8', | ||
'Accept': 'application/json', | ||
}; | ||
if (config.url && !absoluteUrlRegex.test(config.url)) { | ||
config.headers['X-Requested-With'] = 'XMLHttpRequest'; | ||
if (config.url && !absoluteUrlRegex.test(config.url)) { | ||
headers['X-Requested-With'] = 'XMLHttpRequest'; | ||
const CSRFTokenName = 'X-CSRF-Token'; | ||
const token = Cookies.get(CSRFTokenName); | ||
if (token) { | ||
config.headers[CSRFTokenName] = token; | ||
} | ||
const CSRFTokenName = 'X-CSRF-Token'; | ||
const token = Cookies.get(CSRFTokenName); | ||
if (token) { | ||
headers[CSRFTokenName] = token; | ||
} | ||
} | ||
config.headers = { ...headers, ...config.headers }; | ||
return config; | ||
@@ -93,0 +93,0 @@ }); |
Sorry, the diff of this file is not supported yet
53360
961