diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2009-01-16 09:16:18 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2009-02-22 15:35:22 +1300 |
commit | 3248553d3299cbb723f1b4103c16bad7ecdd24a6 (patch) | |
tree | e6e12e1d5845cec8c4c2ef348bee43ff39a11eb0 /actionpack/lib/action_controller/routing | |
parent | f7a0a394f48a0f21e686f891546d17ce33c7840e (diff) | |
download | rails-3248553d3299cbb723f1b4103c16bad7ecdd24a6.tar.gz rails-3248553d3299cbb723f1b4103c16bad7ecdd24a6.tar.bz2 rails-3248553d3299cbb723f1b4103c16bad7ecdd24a6.zip |
Fix requirements regexp for path segments
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1772 state:committed]
Diffstat (limited to 'actionpack/lib/action_controller/routing')
-rw-r--r-- | actionpack/lib/action_controller/routing/segments.rb | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/actionpack/lib/action_controller/routing/segments.rb b/actionpack/lib/action_controller/routing/segments.rb index a5e3b95f31..129e87c139 100644 --- a/actionpack/lib/action_controller/routing/segments.rb +++ b/actionpack/lib/action_controller/routing/segments.rb @@ -191,23 +191,19 @@ module ActionController end def regexp_chunk - if regexp - if regexp_has_modifiers? - "(#{regexp.to_s})" - else - "(#{regexp.source})" - end - else - "([^#{Routing::SEPARATORS.join}]+)" - end + regexp ? regexp_string : default_regexp_chunk + end + + def regexp_string + regexp_has_modifiers? ? "(#{regexp.to_s})" : "(#{regexp.source})" + end + + def default_regexp_chunk + "([^#{Routing::SEPARATORS.join}]+)" end def number_of_captures - if regexp - regexp.number_of_captures + 1 - else - 1 - end + regexp ? regexp.number_of_captures + 1 : 1 end def build_pattern(pattern) @@ -285,8 +281,8 @@ module ActionController "params[:#{key}] = PathSegment::Result.new_escaped((match[#{next_capture}]#{" || " + default.inspect if default}).split('/'))#{" if match[" + next_capture + "]" if !default}" end - def regexp_chunk - regexp || "(.*)" + def default_regexp_chunk + "(.*)" end def number_of_captures |