<commit_before>import findCountryCode from './findCountryCode.js';

export default function createHitFormatter({formatAutocompleteSuggestion, formatInputValue}) {
  return hit => {
    let formatted = {
      administrative: hit.administrative && hit.administrative[0],
      city: hit.city && hit.city.default[0],
      country: hit.country.default,
      countryCode: findCountryCode(hit._tags),
      isCity: hit.is_city,
      name: hit.locale_names.default[0]
    };

    // this is the value to put inside the input.value
    // autocomplete.js automatically takes hit.value as the underlying
    // input value when a suggestion is validated with enter or selected with the mouse
    formatted.value = formatInputValue(formatted);

    // this is the value shown in suggestions, we highlight the name
    formatted.suggestion = formatAutocompleteSuggestion({
      ...formatted,
      name: hit._highlightResult.locale_names.default[0].value
    });

    return formatted;
  };
}<commit_msg>fix(dropdown): trim whitespace in locale name<commit_after>import findCountryCode from './findCountryCode.js';

export default function createHitFormatter({formatAutocompleteSuggestion, formatInputValue}) {
  return hit => {
    let formatted = {
      administrative: hit.administrative && hit.administrative[0],
      city: hit.city && hit.city.default[0],
      country: hit.country.default,
      countryCode: findCountryCode(hit._tags),
      isCity: hit.is_city,
      name: hit.locale_names.default[0].trim() // trim should be done in data, waiting for a fix in Places API
    };

    // this is the value to put inside the input.value
    // autocomplete.js automatically takes hit.value as the underlying
    // input value when a suggestion is validated with enter or selected with the mouse
    formatted.value = formatInputValue(formatted);

    // this is the value shown in suggestions, we highlight the name
    formatted.suggestion = formatAutocompleteSuggestion({
      ...formatted,
      name: hit._highlightResult.locale_names.default[0].value.trim()
    });

    return formatted;
  };
}
{'fraction_non_alphanumeric': 0.09591642924976258, 'fraction_numerical': 0.003798670465337132, 'mean_word_length': 3.4829787234042553, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7455200', 'n_tokens_mistral': 579, 'n_tokens_neox': 552, 'n_words': 172}