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 CHANGED
@@ -1,3 +1,3 @@
1
1
  module Golf
2
- VERSION = "0.7.5"
2
+ VERSION = "0.7.6"
3
3
  end
@@ -724,7 +724,8 @@ $.golf = {
724
724
  },
725
725
 
726
726
  route: function(hash, b) {
727
- var theHash, theRoute, theAction, i, x, pat, match;
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 = "^"+$.golf.controller[i].route+"$";
742
- match = $.isFunction(theRoute) ? theRoute(theHash)
743
- : theHash.match(new RegExp(theRoute));
744
- if (match)
745
- (theAction = $.golf.controller[i].action)(b, match);
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 "
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 5
9
- version: 0.7.5
8
+ - 6
9
+ version: 0.7.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Micha Niskin, Alan Dipert, Julio Capote