From 90ed807eccc0d991529fed597822c8d9481a9b8d Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Sun, 21 Feb 2016 11:43:02 +0100 Subject: [PATCH] fix(request): Improve json content-type detection 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 --- src/request-api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/request-api.js b/src/request-api.js index 2f6ef176f..37ef7d75b 100644 --- a/src/request-api.js +++ b/src/request-api.js @@ -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}`)