aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/regexp.rb
diff options
context:
space:
mode:
authorJeffrey Hardy <packagethief@gmail.com>2009-08-26 12:10:42 -0400
committerJeremy Kemper <jeremy@bitsweat.net>2009-08-26 14:46:38 -0700
commit66d8063c910b166e58f77ca5149a454f721667c7 (patch)
treeeb2d8cfddd7312f4f441ca4e14aa81b645ec9960 /activesupport/lib/active_support/core_ext/regexp.rb
parent05b529ca57f75ce64540b9d34597e0c3bfe1fca7 (diff)
downloadrails-66d8063c910b166e58f77ca5149a454f721667c7.tar.gz
rails-66d8063c910b166e58f77ca5149a454f721667c7.tar.bz2
rails-66d8063c910b166e58f77ca5149a454f721667c7.zip
Correct Regexp#un/optionalize assertions and fix uncovered failures
[#3102 state:incomplete] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activesupport/lib/active_support/core_ext/regexp.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/regexp.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/regexp.rb b/activesupport/lib/active_support/core_ext/regexp.rb
index 1a04c70d87..95d06ee6ee 100644
--- a/activesupport/lib/active_support/core_ext/regexp.rb
+++ b/activesupport/lib/active_support/core_ext/regexp.rb
@@ -9,6 +9,8 @@ class Regexp #:nodoc:
class << self
def optionalize(pattern)
+ return pattern if pattern == ""
+
case unoptionalize(pattern)
when /\A(.|\(.*\))\Z/ then "#{pattern}?"
else "(?:#{pattern})?"