Skip to content

Commit 4a4bcc4

Browse files
committed
Fixing bug caused by default values overriding custom data values in RouteResult
1 parent ee47b8e commit 4a4bcc4

13 files changed

Lines changed: 2677 additions & 249 deletions

‎Core/JavaScript/RouteManager.js‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
/// <summary>Gets the parameters from a URL pattern.</summary>
5454
/// <param name="pattern" mayBeNull="false" optional="false" type="String" parameterArray="false" integer="false" domElement="false">URL pattern defined by a route.</param>
5555
/// <returns type="Array" integer="false" domElement="false" mayBeNull="false" elementType="String" elementInteger="false" elementDomElement="false" elementMayBeNull="false">All parameters of the route.</returns>
56-
56+
5757
var params = [];
5858
$.each(pattern.match(constants.groupParameters) || [], function (i, param) {
5959
params[i] = param.replace(constants.beginAndEndTag, '');
@@ -124,7 +124,7 @@
124124
/// <summary>Gets the route result for the given data values</summary>
125125
/// <param name="data" mayBeNull="false" optional="false" type="Object" parameterArray="false" integer="false" domElement="false">Data used to format the route by replacing parameters in the route pattern with data values</param>
126126
/// <returns type="RouteResult" integer="false" domElement="false" mayBeNull="false">Route value object with route URL</returns>
127-
127+
128128
for (var i = 0; i < this.routes.length; i++) {
129129
if (this.routes[i].accept(data)) {
130130
return this.routes[i].toResult(data);
@@ -142,7 +142,21 @@
142142
if (!this.controllers[controller]) {
143143
this.controllers[controller] = new Object();
144144
}
145-
this.controllers[controller][action] = fn;
145+
146+
if (this.controllers[controller][action]) {
147+
var startsWith = new RegExp('^' + action);
148+
var c = 0;
149+
$.each(this.controllers[controller], function (name, val) {
150+
if (startsWith.test(name)) {
151+
c++;
152+
}
153+
});
154+
155+
this.controllers[controller][action + c] = fn;
156+
}
157+
else {
158+
this.controllers[controller][action] = fn;
159+
}
146160
}
147161

148162
this.namedAction = function (name, data) {
@@ -164,7 +178,7 @@
164178

165179
var _this = this;
166180

167-
this.constraints = [];
181+
this.constraints = [];
168182

169183
this.pattern = pattern;
170