Guest User

Untitled

a guest
Feb 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. diff --git a/vendor/rails/actionpack/lib/action_controller/routing.rb b/vendor/rails/actionpack/lib/action_controller/routing.rb
  2. index edd4683..3de5a08 100644
  3. --- a/vendor/rails/actionpack/lib/action_controller/routing.rb
  4. +++ b/vendor/rails/actionpack/lib/action_controller/routing.rb
  5. @@ -702,9 +702,11 @@ module ActionController
  6.  
  7. def initialize(key = nil, options = {})
  8. super()
  9. - self.key = key
  10. - self.default = options[:default] if options.key? :default
  11. - self.is_optional = true if options[:optional] || options.key?(:default)
  12. + @key = key
  13. + unless @default = options[:default]
  14. + @default = nil
  15. + end
  16. + @is_optional = true if options[:optional] || @default
  17. end
  18.  
  19. def to_s
  20. @@ -855,19 +857,22 @@ module ActionController
  21. end
  22.  
  23. class RouteBuilder #:nodoc:
  24. - attr_accessor :separators, :optional_separators
  25. + attr_accessor :optional_separators
  26. +
  27. + SEPARATORS = Routing::SEPARATORS
  28. + SEPARATOR_PATTERN_AS_STRING = "[#{Regexp.escape(SEPARATORS.join).to_s}]"
  29. + SEPARATOR_PATTERN_AS_REGEXP = Regexp.new(SEPARATOR_PATTERN_AS_STRING)
  30.  
  31. def initialize
  32. - self.separators = Routing::SEPARATORS
  33. self.optional_separators = %w( / )
  34. end
  35.  
  36. def separator_pattern(inverted = false)
  37. - "[#{'^' if inverted}#{Regexp.escape(separators.join)}]"
  38. + SEPARATOR_PATTERN_AS_STRING
  39. end
  40.  
  41. def interval_regexp
  42. - Regexp.new "(.*?)(#{separators.source}|$)"
  43. + Regexp.new "(.*?)(#{SEPARATORS.source}|$)"
  44. end
  45.  
  46. # Accepts a "route path" (a string defining a route), and returns the array
  47. @@ -902,7 +907,7 @@ module ActionController
  48. segment.is_optional = true
  49. end
  50. when /\A(#{separator_pattern(:inverted)}+)/ then StaticSegment.new($1)
  51. - when Regexp.new(separator_pattern) then
  52. + when SEPARATOR_PATTERN_AS_REGEXP then
  53. returning segment = DividerSegment.new($&) do
  54. segment.is_optional = (optional_separators.include? $&)
  55. end
Add Comment
Please, Sign In to add comment