From 66d8063c910b166e58f77ca5149a454f721667c7 Mon Sep 17 00:00:00 2001 From: Jeffrey Hardy Date: Wed, 26 Aug 2009 12:10:42 -0400 Subject: Correct Regexp#un/optionalize assertions and fix uncovered failures [#3102 state:incomplete] Signed-off-by: Jeremy Kemper --- activesupport/lib/active_support/core_ext/regexp.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activesupport/lib/active_support/core_ext/regexp.rb') 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})?" -- cgit v1.2.3