8000 Merge pull request #37 from ruipgil/master · ryanrain2016/javascript-client@26cad75 · GitHub
[go: up one dir, main page]

Skip to content

Commit 26cad75

Browse files
authored
Merge pull request core-api#37 from ruipgil/master
Fix null contentType in negotiateDecoder
2 parents f8913a1 + 986449d commit 26cad75

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const determineTransport = function (transports, url) {
1414
}
1515

1616
const negotiateDecoder = function (decoders, contentType) {
17-
if (contentType === undefined) {
17+
if (contentType === undefined || contentType === null) {
1818
return decoders[0]
1919
}
2020

tests/utils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ describe('Test the Utils/negotiateDecoder function', function () {
2929
expect(result instanceof coreapi.codecs.CoreJSONCodec).toBeTruthy()
3030
})
3131

32+
it('should return the default decoder if content type is null', function () {
33+
const contentType = null
34+
const result = utils.negotiateDecoder(decoders, contentType)
35+
expect(result instanceof coreapi.codecs.CoreJSONCodec).toBeTruthy()
36+
})
37+
3238
it('should return the decoder for a content type (application/json)', function () {
3339
const contentType = 'application/json'
3440
const result = utils.negotiateDecoder(decoders, contentType)

0 commit comments

Comments
 (0)
0