millermedeiros / crossroads.js

JavaScript Routes
http://millermedeiros.github.com/crossroads.js/
1.44k stars 156 forks source link

interpolate do not work on integers #54

Closed yauhen closed 12 years ago

yauhen commented 12 years ago

1) var route = crossroads.addRoute('/news/{id}', function (id) { console.log(id); // 12 (remove trailing zeroes since it's typecasted) }); route.interpolate({ id: 123 });

just fails due of SCRIPT438: Object doesn't support property or method 'indexOf' pattern_lexer.js, line 168 character 25

2) also if we have empty value {id:''} for following route "{id}/:otherId:" it also fails on validation

millermedeiros commented 12 years ago
  1. the error about the indexOf is because it was expecting a string, will fix it for next version (ensure it typecast value to string).
  2. the second one is because it expects id to be a non-empty string since it's a required segment of the route, otherId could be an empty string tho. It should at least give a better error message on the next version. The string "" wouldn't match the route {id}/:otherId: anyway.

Thanks for the feedback.