Permalink
Browse files

fixing wildcard path matching when wildcard is inside parenthesis

  • Loading branch information...
1 parent e4a7b23 commit ba43b9bf5f8a85759939462944f4994c9b1e1ac9 @tenderlove tenderlove committed Jul 27, 2011
Showing with 8 additions and 1 deletion.
  1. +1 −1 actionpack/lib/action_dispatch/routing/mapper.rb
  2. +7 −0 actionpack/test/dispatch/mapper_test.rb
@@ -51,7 +51,7 @@ class Mapping #:nodoc:
IGNORE_OPTIONS = [:to, :as, :via, :on, :constraints, :defaults, :only, :except, :anchor, :shallow, :shallow_path, :shallow_prefix]
ANCHOR_CHARACTERS_REGEX = %r{\A(\\A|\^)|(\\Z|\\z|\$)\Z}
SHORTHAND_REGEX = %r{^/[\w/]+$}
- WILDCARD_PATH = %r{\*([^/]+)$}
+ WILDCARD_PATH = %r{\*([^/\)]+)\)?$}
def initialize(set, scope, path, options)
@set, @scope = set, scope
@@ -35,6 +35,13 @@ def test_initialize
Mapper.new FakeSet.new
end
+ def test_mapping_requirements
+ options = { :controller => 'foo', :action => 'bar' }
+ m = Mapper::Mapping.new FakeSet.new, {}, '/store/:name(*rest)', options
+ _, _, requirements, _ = m.to_route
+ assert_equal(/.+?/, requirements[:rest])
+ end
+
def test_map_slash
fakeset = FakeSet.new
mapper = Mapper.new fakeset

0 comments on commit ba43b9b

Please sign in to comment.