lib/zxcvbn/matching.rb in zxcvbn-0.1.12 vs lib/zxcvbn/matching.rb in zxcvbn-0.1.13

- old
+ new

@@ -14,11 +14,11 @@ RANKED_DICTIONARIES = Zxcvbn.frequency_lists.transform_values do |lst| build_ranked_dict(lst) end RANKED_DICTIONARIES_MAX_WORD_SIZE = RANKED_DICTIONARIES.transform_values do |word_scores| - word_scores.keys.max_by(&:size).size + word_scores.each_key.max_by(&:size)&.size || 0 end GRAPHS = { "qwerty" => ADJACENCY_GRAPHS["qwerty"], "dvorak" => ADJACENCY_GRAPHS["dvorak"], @@ -157,10 +157,10 @@ def self.check_dictionary(matches, password, dictionary_name, ranked_dict) len = password.length password_lower = password.downcase longest_word_size = RANKED_DICTIONARIES_MAX_WORD_SIZE.fetch(dictionary_name) do - ranked_dict.keys.max_by(&:size)&.size || 0 + ranked_dict.each_key.max_by(&:size)&.size || 0 end search_width = [longest_word_size, len].min (0...len).each do |i| search_end = [i + search_width, len].min (i...search_end).each do |j|