Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

isJson method in JSON Interceptor is not spec compliant. #665

@ghost

Description

Reproduction

Passing this payload to the isJson interceptor method: "↵[{"foo":"bar"}] (Where is %x0A or new line) evaluates to false.

What is Expected?

Per the spec on https://tools.ietf.org/html/rfc7159#page-5 : "Insignificant whitespace is allowed before or after any of the six structural characters.", thus this should evaluate to true.

EDIT:

I suggested to add \s* to the regex, but this doesn't include the fact that true, false, null, numbers and string literals are also valid. Although I suspect that including string and number literals is not desirable.
https://github.com/pagekit/vue-resource/blob/master/src/http/interceptor/json.js#L43

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions