diff options
Diffstat (limited to 'lib/rack/core_ext/regexp.rb')
-rw-r--r-- | lib/rack/core_ext/regexp.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/rack/core_ext/regexp.rb b/lib/rack/core_ext/regexp.rb new file mode 100644 index 00000000..02975345 --- /dev/null +++ b/lib/rack/core_ext/regexp.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +# Regexp has `match?` since Ruby 2.4 +# so to support Ruby < 2.4 we need to define this method + +module Rack + module RegexpExtensions + if Gem::Version.new(RUBY_VERSION) < Gem::Version.new(2.4) + refine Regexp do + def match?(string, pos = 0) + !!match(string, pos) + end unless //.respond_to?(:match?) + end + end + end +end |