Skip to content

Commit

Permalink
chore: ensure headers are case insensitive
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Tomic <16724532+boristomic@users.noreply.github.com>
  • Loading branch information
boristomic committed Dec 4, 2023
1 parent c450977 commit b768554
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,16 @@ export class RequestWrapper {
}

private isJsonResponse<T extends TransformedResponse | AxiosResponse>(response: T) {
return response.headers['content-type'] &&
response.headers['content-type'].indexOf('application/json') !== -1;
let headers: RawAxiosResponseHeaders | AxiosResponseHeaders = {};
Object.assign(headers, response.headers);
headers = Object.entries(response.headers)
.reduce((acc: RawAxiosResponseHeaders | AxiosResponseHeaders, [key, val]) => {
acc[key.toLowerCase()] = val.toLowerCase();
return acc;
}, ({}));

return headers['content-type'] &&
headers['content-type'].indexOf('application/json') !== -1;
}

private getLogParameters(extraParametersToLog = {}) {
Expand Down

0 comments on commit b768554

Please sign in to comment.