Skip to content

isJSONContent fails when directives in Content-Type header are present #1229

@ctstone

Description

@ctstone

What is the expected behavior?

common.isJSONContent('application/json; charset=utf-8') === true

What is the actual behavior?

common.isJSONContent('application/json; charset=utf-8') === false

Possible solution
Change implementation to:

return contentType.startsWith('application/json');
// or contentType.indexOf('application/json') === 0

How to reproduce the issue
Use the recorder to capture a request using an HTTP client that uses the charset directive in the Content-Type header. E.g., ms-rest

Does the bug have a test case?

Runkit

Versions

Software Version(s)
Nock 9.6.1
Node 8.11.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions