-
23 Aug 2011 5:56 AM #1
Ext.Router should handle trailing slashes
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.
cheersCode: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 + "/?$"); }
michael
-
23 Aug 2011 3:17 PM #2
I've submitted this one to Engineering, thanks for reporting
-
7 Nov 2011 2:23 AM #3
HOW to
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
-
8 Nov 2011 1:00 AM #4
You need to fix this directly in the sencha touch code, so it would be best to create an override for this method.
-
8 Nov 2011 2:04 AM #5
@mike Got it Thanks a lot!
@mike Got it Thanks a lot!
Thanks for reply man,
have a great day!
-
2 Feb 2012 12:53 PM #6Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
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.Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
-
2 Feb 2012 12:54 PM #7Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
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(); }); });Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote