From f7a0a394f48a0f21e686f891546d17ce33c7840e Mon Sep 17 00:00:00 2001 From: Andrew White Date: Sat, 7 Feb 2009 14:44:50 +0000 Subject: Remove hardcoded number_of_capturesin ControllerSegment to allow regexp requirements with capturing parentheses Signed-off-by: Michael Koziarski [#1887 state:committed] --- actionpack/lib/action_controller/routing/segments.rb | 4 ---- 1 file changed, 4 deletions(-) (limited to 'actionpack/lib/action_controller/routing') diff --git a/actionpack/lib/action_controller/routing/segments.rb b/actionpack/lib/action_controller/routing/segments.rb index 5dda3d4d00..a5e3b95f31 100644 --- a/actionpack/lib/action_controller/routing/segments.rb +++ b/actionpack/lib/action_controller/routing/segments.rb @@ -244,10 +244,6 @@ module ActionController "(?i-:(#{(regexp || Regexp.union(*possible_names)).source}))" end - def number_of_captures - 1 - end - # Don't URI.escape the controller name since it may contain slashes. def interpolation_chunk(value_code = local_name) "\#{#{value_code}.to_s}" -- cgit v1.2.3 From 3248553d3299cbb723f1b4103c16bad7ecdd24a6 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Fri, 16 Jan 2009 09:16:18 +0000 Subject: Fix requirements regexp for path segments Signed-off-by: Michael Koziarski [#1772 state:committed] --- .../lib/action_controller/routing/segments.rb | 28 ++++++++++------------ 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'actionpack/lib/action_controller/routing') 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 -- cgit v1.2.3 From 0a8c003b1e0459b5bcfa47f49cc74f7a6b3851f8 Mon Sep 17 00:00:00 2001 From: Sam Granieri Date: Sun, 22 Feb 2009 21:24:53 -0600 Subject: Ruby 1.9 compat: silence a warning about regexp languages [#2050 state:committed] Signed-off-by: Jeremy Kemper --- actionpack/lib/action_controller/routing/segments.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/routing') diff --git a/actionpack/lib/action_controller/routing/segments.rb b/actionpack/lib/action_controller/routing/segments.rb index 129e87c139..cbb1a9c09a 100644 --- a/actionpack/lib/action_controller/routing/segments.rb +++ b/actionpack/lib/action_controller/routing/segments.rb @@ -3,7 +3,11 @@ module ActionController class Segment #:nodoc: RESERVED_PCHAR = ':@&=+$,;' SAFE_PCHAR = "#{URI::REGEXP::PATTERN::UNRESERVED}#{RESERVED_PCHAR}" - UNSAFE_PCHAR = Regexp.new("[^#{SAFE_PCHAR}]", false, 'N').freeze + if RUBY_VERSION >= '1.9' + UNSAFE_PCHAR = Regexp.new("[^#{SAFE_PCHAR}]", false).freeze + else + UNSAFE_PCHAR = Regexp.new("[^#{SAFE_PCHAR}]", false, 'N').freeze + end # TODO: Convert :is_optional accessor to read only attr_accessor :is_optional -- cgit v1.2.3 From ce56c5daa81d61a745b88220014a846a0eea46a4 Mon Sep 17 00:00:00 2001 From: Mike Gunderloy Date: Tue, 3 Mar 2009 17:40:39 -0600 Subject: Allow routes with a trailing slash to be recognized Signed-off-by: Michael Koziarski [#2039 state:committed] --- actionpack/lib/action_controller/routing/segments.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/routing') diff --git a/actionpack/lib/action_controller/routing/segments.rb b/actionpack/lib/action_controller/routing/segments.rb index cbb1a9c09a..358b4a6487 100644 --- a/actionpack/lib/action_controller/routing/segments.rb +++ b/actionpack/lib/action_controller/routing/segments.rb @@ -318,7 +318,7 @@ module ActionController end def regexp_chunk - '(\.[^/?\.]+)?' + '/|(\.[^/?\.]+)?' end def to_s -- cgit v1.2.3 From 638b3b15a13c4e274cfb317c40248e9feea3bfae Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Wed, 4 Mar 2009 14:37:59 -0600 Subject: Generating routes with optional format segment does not inherit params format [#2043 state:resolved] --- actionpack/lib/action_controller/routing/segments.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/routing') diff --git a/actionpack/lib/action_controller/routing/segments.rb b/actionpack/lib/action_controller/routing/segments.rb index 358b4a6487..4f936d51d2 100644 --- a/actionpack/lib/action_controller/routing/segments.rb +++ b/actionpack/lib/action_controller/routing/segments.rb @@ -324,7 +324,11 @@ module ActionController def to_s '(.:format)?' end - + + def extract_value + "#{local_name} = options[:#{key}] && options[:#{key}].to_s.downcase" + end + #the value should not include the period (.) def match_extraction(next_capture) %[ -- cgit v1.2.3 From a0bb8bcb166a9d66c81fd68b8c128fb06d6c725d Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sat, 7 Mar 2009 15:53:09 +0000 Subject: =?UTF-8?q?Remove=20unused=20variable=20[#1451=20state:resolved]?= =?UTF-8?q?=20[Rapha=C3=ABl=20Valyi]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- actionpack/lib/action_controller/routing/recognition_optimisation.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'actionpack/lib/action_controller/routing') diff --git a/actionpack/lib/action_controller/routing/recognition_optimisation.rb b/actionpack/lib/action_controller/routing/recognition_optimisation.rb index ebc553512f..9bfebff0c0 100644 --- a/actionpack/lib/action_controller/routing/recognition_optimisation.rb +++ b/actionpack/lib/action_controller/routing/recognition_optimisation.rb @@ -98,7 +98,6 @@ module ActionController if Array === item i += 1 start = (i == 1) - final = (i == list.size) tag, sub = item if tag == :dynamic body += padding + "#{start ? 'if' : 'elsif'} true\n" -- cgit v1.2.3 From 90dba00822acd1e01f7a39625668ee74ffe5f061 Mon Sep 17 00:00:00 2001 From: Andrew Bloom Date: Mon, 9 Mar 2009 15:27:13 +0000 Subject: Ensure blank path_prefix works as expected [#2122 state:resolved] Signed-off-by: Pratik Naik --- actionpack/lib/action_controller/routing/builder.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/routing') diff --git a/actionpack/lib/action_controller/routing/builder.rb b/actionpack/lib/action_controller/routing/builder.rb index 44d759444a..d9590c88b8 100644 --- a/actionpack/lib/action_controller/routing/builder.rb +++ b/actionpack/lib/action_controller/routing/builder.rb @@ -159,7 +159,8 @@ module ActionController path = "/#{path}" unless path[0] == ?/ path = "#{path}/" unless path[-1] == ?/ - path = "/#{options[:path_prefix].to_s.gsub(/^\//,'')}#{path}" if options[:path_prefix] + prefix = options[:path_prefix].to_s.gsub(/^\//,'') + path = "/#{prefix}#{path}" unless prefix.blank? segments = segments_for_route_path(path) defaults, requirements, conditions = divide_route_options(segments, options) -- cgit v1.2.3