class ElasticAPM::Config::WildcardPatternList::WildcardPattern
@api private
def convert(str)
def convert(str) case_sensitive = false if str.start_with?('(?-i)') str = str.gsub(/^\(\?-\i\)/, '') case_sensitive = true end parts = str.chars.each_with_object([]) do |char, arr| arr << (char == '*' ? '.*' : Regexp.escape(char)) end Regexp.new( '\A' + parts.join + '\Z', case_sensitive ? nil : Regexp::IGNORECASE ) end
def initialize(str)
def initialize(str) @pattern = convert(str) end
def match?(other)
def match?(other) !!@pattern.match(other) end