Looks like we can't reproduce the issue or there's a problem in the test case provided.
-
Sencha User
Ext.Router should handle trailing slashes
I just spent a lot of time debugging my app because it wouldn't redirect to one of my custom routes. In the end I found that a simple trailing slash at the end of the url broke the whole route recognizer and the router just failed silently, which could be avoided with a simple fix.
Code:
createMatcherRegex: function(url) {
var paramsInMatchString = this.paramsInMatchString,
length = paramsInMatchString.length,
i, cond, matcher;
for (i = 0; i < length; i++) {
cond = this.conditions[paramsInMatchString[i]];
matcher = Ext.util.Format.format("({0})", cond || "[%a-zA-Z0-9\\_\\s,]+");
url = url.replace(new RegExp(paramsInMatchString[i]), matcher);
}
return new RegExp("^" + url + "/?$");
}
cheers
michael
-
Sencha - Engineering Operations
I've submitted this one to Engineering, thanks for reporting
-
Sencha User
HOW to
Hi Michael,
thanks for this post, i've been struggling with the same problem.
un fortunately i'm did'nt really grasped where to use this code: inside the router.js, or within the controller?
Can you please provide some details on how to use this solution?
Thanks a lot in advance
Guido Serio
-
Sencha User
You need to fix this directly in the sencha touch code, so it would be best to create an override for this method.
-
Sencha User
@mike Got it Thanks a lot!
Thanks for reply man,
have a great day!
-
I don't think I agree with this. If the url has a trailing slash but the route is not set up to handle this, then it shouldn't match. If we start adding exceptions to this we'll be back next week when a route doesn't match a trailing question mark, or comma, or number or random letter.
I'm going to mark this one as a won't fix for now.
-
BTW if you do specify a trailing slash then this passes:
Code:
describe("a url with a trailing slash", function() {
beforeEach(function() {
route = Ext.create('Ext.app.Route', {
url: ':controller/:action/'
});
});
it("should match a url with a trailing slash", function() {
expect(route.recognize('someController/someAction/')).toBeTruthy();
});
});