class Honeybadger::Util::Sanitizer
def initialize(max_depth: 20, filters: [])
def initialize(max_depth: 20, filters: []) @filters = !filters.empty? @max_depth = max_depth strings, @regexps, @blocks = [], [], [] filters.each do |item| case item when Proc @blocks << item when Regexp @regexps << item else strings << Regexp.escape(item.to_s) end end @deep_regexps, @regexps = @regexps.partition { |r| r.to_s.include?('\\.'.freeze) } deep_strings, @strings = strings.partition { |s| s.include?('\\.'.freeze) } @regexps << Regexp.new(strings.join("|".freeze), true) unless strings.empty? @deep_regexps << Regexp.new(deep_strings.join("|".freeze), true) unless deep_strings.empty? end