View Full Version : [CLOSED] Ext.Router should handle trailing slashes

23 Aug 2011, 5:56 AM
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.

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 + "/?$");


23 Aug 2011, 3:17 PM
I've submitted this one to Engineering, thanks for reporting

7 Nov 2011, 2:23 AM
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
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
Thanks for reply man,
have a great day!

2 Feb 2012, 12:53 PM
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.

2 Feb 2012, 12:54 PM
BTW if you do specify a trailing slash then this passes:

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() {