Changeset 9115 for trunk/actionpack/lib/action_controller/routing
- Timestamp:
- 03/28/08 20:01:21 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/routing/builder.rb
r8652 r9115 15 15 def interval_regexp 16 16 Regexp.new "(.*?)(#{separators.source}|$)" 17 end 18 19 def multiline_regexp?(expression) 20 expression.options & Regexp::MULTILINE == Regexp::MULTILINE 17 21 end 18 22 … … 99 103 if requirement.source =~ %r{\A(\\A|\^)|(\\Z|\\z|\$)\Z} 100 104 raise ArgumentError, "Regexp anchor characters are not allowed in routing requirements: #{requirement.inspect}" 105 end 106 if multiline_regexp?(requirement) 107 raise ArgumentError, "Regexp multiline option not allowed in routing requirements: #{requirement.inspect}" 101 108 end 102 109 segment.regexp = requirement trunk/actionpack/lib/action_controller/routing/route.rb
r8652 r9115 63 63 requirement_conditions = requirements.collect do |key, req| 64 64 if req.is_a? Regexp 65 value_regexp = Regexp.new "\\A#{req. source}\\Z"65 value_regexp = Regexp.new "\\A#{req.to_s}\\Z" 66 66 "hash[:#{key}] && #{value_regexp.inspect} =~ options[:#{key}]" 67 67 else trunk/actionpack/lib/action_controller/routing/segments.rb
r8652 r9115 172 172 173 173 def value_regexp 174 Regexp.new "\\A#{regexp.source}\\Z" if regexp 175 end 176 def regexp_chunk 177 regexp ? "(#{regexp.source})" : "([^#{Routing::SEPARATORS.join}]+)" 174 Regexp.new "\\A#{regexp.to_s}\\Z" if regexp 175 end 176 177 def regexp_chunk 178 if regexp 179 if regexp_has_modifiers? 180 "(#{regexp.to_s})" 181 else 182 "(#{regexp.source})" 183 end 184 else 185 "([^#{Routing::SEPARATORS.join}]+)" 186 end 178 187 end 179 188 … … 184 193 optional? ? Regexp.optionalize(pattern) : pattern 185 194 end 195 186 196 def match_extraction(next_capture) 187 197 # All non code-related keys (such as :id, :slug) are URI-unescaped as … … 202 212 end 203 213 214 def regexp_has_modifiers? 215 regexp.options & (Regexp::IGNORECASE | Regexp::EXTENDED) != 0 216 end 217 204 218 end 205 219