Skip to content

Commit 31f5b4b

Browse files
authored
fix: More inclusive json mime type (#52)
Instead of exact json type response is now checked that it includes application/json as a substring of Content-Type. Allows more variants like charset
1 parent 61c6ca2 commit 31f5b4b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/api-request.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ export class LastFMApiRequest<T> {
9191

9292
httpRequest.end();
9393
}).then(([response, content]) => {
94-
if (response.headers['content-type'] !== 'application/json') {
94+
if (!response.headers['content-type']?.includes('application/json')) {
9595
throw new LastFMResponseError(
96-
`lastfm-ts-api: Expected JSON response but received '${response.headers['content-type']}'`,
96+
`lastfm-ts-api: Expected JSON response ('application/json') but received '${response.headers['content-type']}'`,
9797
{ response, content }
9898
);
9999
}

0 commit comments

Comments
 (0)