fix(tracker): fix axios header string format, sanitizer check; tracker 7.0.2

This commit is contained in:
nick-delirium 2023-05-26 16:24:12 +02:00
parent 7873bc3ff9
commit 3ad78f9ffe
2 changed files with 15 additions and 12 deletions

View file

@ -1,3 +1,7 @@
# 7.0.2
- fixed header sanitization for axios causing empty string in some cases
# 7.0.1
- fix time inputs capturing

View file

@ -259,17 +259,16 @@ export default function (app: App, opts: Partial<Options> = {}) {
const { headers: reqHs, body: reqBody } = getXHRRequestDataObject(xhr)
const duration = startTime > 0 ? e.timeStamp - startTime : 0
const hString: string | null = ignoreHeaders ? '' : xhr.getAllResponseHeaders() // might be null (though only if no response received though)
const resHs = hString
? hString
.split('\r\n')
.map((h) => h.split(':'))
.filter((entry) => !isHIgnored(entry[0]))
.reduce(
(hds, [name, value]) => ({ ...hds, [name]: value }),
{} as Record<string, string>,
)
: {}
const hString: string | null = xhr.getAllResponseHeaders() // might be null (though only if no response received though)
const headersArr = hString.trim().split(/[\r\n]+/)
const headerMap: Record<string, string> = {}
headersArr.forEach(function (line) {
const parts = line.split(': ')
const header = parts.shift() as unknown as string
if (!isHIgnored(header)) {
headerMap[header] = parts.join(': ')
}
})
const method = strMethod(initMethod)
const reqResInfo = sanitize({
@ -281,7 +280,7 @@ export default function (app: App, opts: Partial<Options> = {}) {
body: reqBody,
},
response: {
headers: resHs,
headers: headerMap,
body: xhr.response,
},
})