Sencha Touch 1.1.1
In my ‘route.js’ for Ext.Router.draw, I have custom route “map.connect” like:
Ext.Router.draw(function(map) { map.connect('s/:specialName', { controller: 'Special', action: 'index' }); map.connect(':controller/:action'); });
The URL I used is like this “http://localhost/m/#s/am-i-right-3023”, which contains dash(-) in the URL.
If I refresh the browser with the URL, application is not reloading the page properly.
Apparently, Sencha Touch router does not accept dash(-) for the history URL.
So, I had a look Sencha Touch source code and found the line to define Regex for URL:
[line: 10729]
Ext.util.Route = Ext.extend(Object, { constructor: function(config) { Ext.apply(this, config, { conditions: {} }); this.paramMatchingRegex = new RegExp(/:([0-9A-Za-z\_]*)/g); this.paramsInMatchString = this.url.match(this.paramMatchingRegex) || []; this.matcherRegex = this.createMatcherRegex(this.url); },
[line: 10786]
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 + "$"); }
It looks like paramMatchingRegex is forced to be set or I could not find the way to pass new Regex?
In anyway, to solve quickly, I modified below code[line:10794]:
matcher = Ext.util.Format.format("({0})", cond || "[%a-zA-Z0-9\\_\\s,]+");
to
matcher = Ext.util.Format.format("({0})", cond || "[%a-zA-Z0-9\-\\_\\s,]+");
It now, accepts dash(-). However, this is not good solution.
Better solution is passing configuration to Ext.util.Route from ‘route.js’.
I should keep looking for solution.