dfilatov/jspath

Unexpected token is thrown when the path contains hyphen

Closed this issue · 1 comments

It's not possible to lookup when there is an hyphen on path.

var object = { something: { anotherthing : { "other-thing" : "abc"} } };
JSPath.apply(".something.anotherthing.other-thing", object);

Uncaught Error: Unexpected token "-"
at throwError (http://localhost:8080/configuration/js/external/bower_components/jspath/lib/jspath.js:636:21)
at throwUnexpected (http://localhost:8080/configuration/js/external/bower_components/jspath/lib/jspath.js:626:9)
at parse (http://localhost:8080/configuration/js/external/bower_components/jspath/lib/jspath.js:58:13)
at compile (http://localhost:8080/configuration/js/external/bower_components/jspath/lib/jspath.js:1269:45)
at Function.decl as apply

You need to quote such things:
JSPath.apply('.something.anotherthing."other-thing"', object);
or if you prefer double quotes for strings:
JSPath.apply(".something.anotherthing.\"other-thing\"", object);