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.
Reproduction
Passing this payload to the isJson interceptor method:
"↵[{"foo":"bar"}]
(Where↵
is%x0A
or new line) evaluates tofalse
.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