Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix(request): Improve json content-type detection
Browse files Browse the repository at this point in the history
js-ipfs serves a content type including the charset
`application/json; charset=utf-8` so the previous check for
json failed, resulting in non parsed json.
Fixes https://github.com/ipfs/js-ipfs/pull/69/files#r53560321
  • Loading branch information
dignifiedquire committed Feb 21, 2016
1 parent 4dc87c7 commit 90ed807
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/request-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function onRes (buffer, cb) {

const stream = !!res.headers['x-stream-output']
const chunkedObjects = !!res.headers['x-chunked-output']
const isJson = res.headers['content-type'] === 'application/json'
const isJson = res.headers['content-type'].indexOf('application/json') === 0

if (res.statusCode >= 400 || !res.statusCode) {
const error = new Error(`Server responded with ${res.statusCode}`)
Expand Down

0 comments on commit 90ed807

Please sign in to comment.