uri-templates icon indicating copy to clipboard operation
uri-templates copied to clipboard

`fromUri()` incorrectly picks up trailing chars

Open jwalton opened this issue 6 years ago • 1 comments

const template = uriTemplate("/foo/{bar}");
const params = template.fromUri('/foo/bar/');
console.log(params.bar);

This prints "bar/". I would expect params to be undefined though, because "/" isn't allowed in a simple expansion?

jwalton avatar Apr 11 '18 00:04 jwalton

Oh, it's not just trialing chars:

const template = new UriTemplate('/a/{b}/c');
template.fromUri('/a/foo/bar/c'); // Returns `{b: 'foo/bar'}`

To my mind this is the main difference between the template '/a/{b}/c' and '/a/{+b}/c' - the first should not allow extra "/"s to match, where the second should.

jwalton avatar Apr 12 '18 14:04 jwalton