pagekit / vue-resource

The HTTP client for Vue.js
MIT License
10.08k stars 1.6k forks source link

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

Closed ghost closed 6 years ago

ghost commented 6 years ago

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

steffans commented 6 years ago

Thanks, fixed in v1.3.5