diff options
Diffstat (limited to 'actionpack/lib/action_controller/routing_optimisation.rb')
-rw-r--r-- | actionpack/lib/action_controller/routing_optimisation.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/routing_optimisation.rb b/actionpack/lib/action_controller/routing_optimisation.rb index 535f1bed63..1b447b17e7 100644 --- a/actionpack/lib/action_controller/routing_optimisation.rb +++ b/actionpack/lib/action_controller/routing_optimisation.rb @@ -62,11 +62,10 @@ module ActionController elements << '#{request.host_with_port}' end - # The last entry in route.segments appears to - # *always* be a 'divider segment' for '/' - # but we have assertions to ensure that we don't - # include the trailing slashes, so skip them - route.segments[0..-2].each do |segment| + # The last entry in route.segments appears to # *always* be a + # 'divider segment' for '/' but we have assertions to ensure that + # we don't include the trailing slashes, so skip them. + ((route.segments.size == 1 && kind == :path) ? route.segments : route.segments[0..-2]).each do |segment| if segment.is_a?(DynamicSegment) elements << "\#{URI.escape(args[#{idx}].to_param, ActionController::Routing::Segment::UNSAFE_PCHAR)}" idx += 1 @@ -96,4 +95,4 @@ module ActionController OPTIMISERS = [PositionalArguments, PositionalArgumentsWithAdditionalParams] end end -end
\ No newline at end of file +end |