Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route.interpolate() generates route without trailing "/" if optional param #116

Open
khakulov opened this issue Nov 6, 2014 · 1 comment
Labels

Comments

@khakulov
Copy link

khakulov commented Nov 6, 2014

This route works fine:

var route1 = crossroads.addRoute('news/{id}/');
route1.interpolate({id: 123});   // "news/123/" --> OK
route1.interpolate({id: 'foo'}); // "news/foo/" --> OK

var route2 = crossroads.addRoute('news/:id:/');
route2.interpolate({id: 123});   // "news/123/" --> OK
route2.interpolate({}); // "news//" --> don't make sense but OK

var route3 = crossroads.addRoute('news:?query:');
route3.interpolate({query: {id: 123}});   // "news?id=123" --> OK
route3.interpolate({}); // "news" --> OK

But this route has no trailing:

var route2 = crossroads.addRoute('news/:id:');
route2.interpolate({id: 123});   // "news/123" --> OK
route2.interpolate({}); // "news" --> WTF --> must be news/

var route4 = crossroads.addRoute('news/:?query:');
route4.interpolate({query: {id: 123}});   // "news/?id=123" --> OK
route4.interpolate({}); // "news" --> WTF must be news/
@millermedeiros
Copy link
Owner

the main issue here is that I'm using RegExp to generate the routes while I should really be using something smarter to do that.. should not be that hard to fix but I probably won't have time to work on it for now. sorry about the huge delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants