diff options
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 503f70bd5f..ca9f00c92e 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -108,12 +108,12 @@ module ActionDispatch end def normalize_options!(options, path_params) - path_without_format = path.sub(/\(\.:format\)$/, '') + wildcards = path_ast(path).grep(Journey::Nodes::Star).map(&:name) # Add a constraint for wildcard route to make it non-greedy and match the # optional format part of the route by default - if path_without_format.match(WILDCARD_PATH) && options[:format] != false - options[$1.to_sym] ||= /.+?/ + if wildcards.any? && options[:format] != false + wildcards.each { |wc| options[wc.to_sym] ||= /.+?/ } end if path_params.include?(:controller) |