-
Notifications
You must be signed in to change notification settings - Fork 421
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
Please add trailing slash support for can.route.pushstate #588
Comments
Can you add a description / example? Why is trailing slash support needed? If you wanted to match everything under |
Trailing slashes are HTTP spec for directories. It's common practice on marketing-type websites (blogs, etc) to simulate folders instead of resources. Would be a good idea to carry this mentality over to apps as they too rely on marketing tactics. If we have an app at |
I can't find a reference for that use of trailing slashes in the HTTP spec. Do you have a link? |
I edited my previous comment a few times to make it more accurate. Please check it out. How does a virtual folder not apply to pushstate? We're already pointing to them, only difference is we're currently forced to end with a resource. |
I still don't really understand. Can you give me a code example or fiddle? Afaik, trailing slashes already work. |
This link ends up going to can.route.bindings.pushstate.root = "/";
can.route(":section");
can.route.ready(); <a href="test/">link</a> This ends up going to can.route.bindings.pushstate.root = "/";
can.route(":section/:sub/");
can.route.ready();
can.route.attr({section:"test",sub:""}); |
Could you change that to: can.route.bindings.pushstate.root = "/";
can.route(":section/");
can.route.ready(); As far as the other example, that is what I would expect. You can probably fix that like: can.route.bindings.pushstate.root = "/";
can.route(":section/",{
sub: ""
});
can.route(":section/:sub/");
can.route.ready();
can.route.attr({section:"test",sub:""}); |
Changing to |
Ok, so that's a bug. I'll try to fix this asap. |
Cool, thank you |
Ok, I created a test that looks like: test("trailing slashes (#588)", function(){
can.route.routes = {};
can.route.bindings.pushstate.root = "/";
can.route(":section/");
res = can.route.param({section: "test"});
equal(res, "test/");
var obj = can.route.deparam("foo/");
deepEqual(obj, {
section : "foo",
route: ":section/"
});
}); And it passes. I'm a bit confused. How are you creating the link? |
If I do:
This calls back the section event handler. You'll notice that the link has to include the root's |
I'm going to close unless as there does not appear to be a bug. Please comment if I'm missing something. |
can.route.bindings.pushstate.root = "/";
can.route(":section/");
can.route.ready();
can.route.attr({section: "test"}); goes to and can.route.bindings.pushstate.root = "/";
can.route(":section/");
can.route.ready();
console.log( can.route.url({section: "test"}) ); gives me am I doing something incorrectly? |
@stevenvachon I'm not sure. Let chat on skype tomorrow: justinbmeyer. |
This is confirmed working with @stevenvachon |
No description provided.
The text was updated successfully, but these errors were encountered: