From 986449d46eb51585293d38fa31cba1e72146c59b Mon Sep 17 00:00:00 2001 From: Rui Gil Date: Mon, 15 May 2017 12:02:12 +0100 Subject: [PATCH 1/2] Fix null contentType in negotiateDecoder --- lib/utils.js | 2 +- tests/utils.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index a969bb6..60b127f 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -14,7 +14,7 @@ const determineTransport = function (transports, url) { } const negotiateDecoder = function (decoders, contentType) { - if (contentType === undefined) { + if (contentType === undefined || contentType === null) { return decoders[0] } diff --git a/tests/utils.js b/tests/utils.js index eb88558..fe31ec3 100644 --- a/tests/utils.js +++ b/tests/utils.js @@ -29,6 +29,12 @@ describe('Test the Utils/negotiateDecoder function', function () { expect(result instanceof coreapi.codecs.CoreJSONCodec).toBeTruthy() }) + it('should return the default decoder if content type is null', function () { + const contentType = null + const result = utils.negotiateDecoder(decoders, contentType) + expect(result instanceof coreapi.codecs.CoreJSONCodec).toBeTruthy() + }) + it('should return the decoder for a content type (application/json)', function () { const contentType = 'application/json' const result = utils.negotiateDecoder(decoders, contentType) From e1f1ecc1b8c5794b197c78d1356b13107bb821d6 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 5 Oct 2017 10:41:02 +0100 Subject: [PATCH 2/2] Version 0.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7813820..1c9eed0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coreapi", - "version": "0.1.0", + "version": "0.1.1", "description": "Javascript client library for Core API", "main": "lib/index.js", "scripts": {