Skip to content

Commit

Permalink
fix: normalise header names in XMLHttpRequestEvent.getResponseHeader
Browse files Browse the repository at this point in the history
  • Loading branch information
kalopilato authored and kettanaito committed Feb 4, 2021
1 parent f558850 commit 79d2ee3
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/interceptors/XMLHttpRequest/XMLHttpRequestOverride.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,7 @@ export const createXMLHttpRequestOverride = (
const headerValue = Object.entries(this.responseHeaders).reduce<
string | null
>((_, [headerName, headerValue]) => {
// Ignore header name casing while still allowing to set response headers
// with an arbitrary casing (no normalization).
if ([headerName, headerName.toLowerCase()].includes(name)) {
return headerValue
}

return null
return (headerName.toLowerCase() === name.toLowerCase()) ? headerValue : null
}, null)

debug('resolved response header', name, headerValue, this.responseHeaders)
Expand Down

0 comments on commit 79d2ee3

Please sign in to comment.