golf 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/golf/version.rb +1 -1
- data/resources/jquery.golf.js +14 -6
- metadata +2 -2
data/lib/golf/version.rb
CHANGED
data/resources/jquery.golf.js
CHANGED
@@ -724,7 +724,8 @@ $.golf = {
|
|
724
724
|
},
|
725
725
|
|
726
726
|
route: function(hash, b) {
|
727
|
-
var theHash, theRoute, theAction, i,
|
727
|
+
var theHash, theRoute, theAction, theParams, i, j, x, match,
|
728
|
+
params;
|
728
729
|
if (!hash)
|
729
730
|
hash = String($.golf.defaultRoute+"/").replace(/\/+$/, "/");
|
730
731
|
|
@@ -738,11 +739,18 @@ $.golf = {
|
|
738
739
|
try {
|
739
740
|
if ($.golf.controller.length > 0) {
|
740
741
|
for (i=0; i<$.golf.controller.length && theAction===null; i++) {
|
741
|
-
theRoute
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
742
|
+
theRoute = $.golf.controller[i].route;
|
743
|
+
theParams = $.map(theRoute.split("/"), function(v,i) {
|
744
|
+
return v.charAt(0) == ":" ? v.substring(1) : null;
|
745
|
+
});
|
746
|
+
theRoute = theRoute.replace(/\/:[^\/]+/g, "/([^/]+)");
|
747
|
+
match = theHash.match(new RegExp("^"+theRoute+"$"));
|
748
|
+
params = {};
|
749
|
+
if (match) {
|
750
|
+
for (j=1; j<match.length; j++)
|
751
|
+
params[theParams[j-1]] = match[j];
|
752
|
+
(theAction = $.golf.controller[i].action)(b, params);
|
753
|
+
}
|
746
754
|
}
|
747
755
|
if (theAction === null)
|
748
756
|
$.golf.errorPage("Not Found", "<span>There is no route "
|