<commit_before>{ diffChars } = require 'diff'
{ isUri, formatUri, parseUri } = require './common'

module.exports = (obj, string) ->
  return string if not isUri(string) or typeof obj isnt 'object'

  hostParsed = parseUri(string)
  differences = null
  match = null

  # Match string by letter according to the spec algorithm:
  # An O(ND) Difference Algorithm by <NAME>
  Object.keys(obj)
    .filter (host) ->
      parseUri(host).hostname is hostParsed.hostname
    .forEach (host) ->
      diffLength = diffChars(host, string).length
      differences = diffLength unless differences
      if diffLength <= differences and match.password
        match = host
        differences = diffLength

  return match<commit_msg>Removing file<commit_after>{ diffChars } = require 'diff'
{ isUri, formatUri, parseUri } = require './common'

module.exports = (obj, string) ->
  return string if not isUri(string) or typeof obj isnt 'object'

  hostParsed = parseUri(string)
  differences = null
  match = null

  # Match string by letter according to the spec algorithm:
  # An O(ND) Difference Algorithm by <NAME>
  Object.keys(obj)
    .filter (host) ->
      parseUri(host).hostname is hostParsed.hostname
    .forEach (host) ->
      diffLength = diffChars(host, string).length
      differences = diffLength unless differences
      if diffLength <= differences
        match = host
        differences = diffLength

  return match
{'fraction_non_alphanumeric': 0.09447165850244926, 'fraction_numerical': 0.0, 'mean_word_length': 3.2686567164179103, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7420945', 'n_tokens_mistral': 405, 'n_tokens_neox': 402, 'n_words': 136}