<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import escapeStringRegexp from 'escape-string-regexp';
import ArrowRightIcon from '../../../../public/images/icon-arrow-right.svg';

const AutoSuggestItem = (props) => {
  const { isActive, onSuggestionSelection, query, content } = props;
  const highlightedSuggestion = content.replace(
    new RegExp(`(${escapeStringRegexp(query)})`, 'gi'),
    '<span class="c-auto-suggest__highlight">$1</span>'
  );

  return (
    <li>
      <button
        type="button"
        className={`c-auto-suggest-item ${isActive ? 'c-auto-suggest-item--active' : ''}`}
        onClick={onSuggestionSelection}
      >
        <span className="icon">
          <ArrowRightIcon />
        </span>
        <span
          // eslint-disable-next-line react/no-danger
          dangerouslySetInnerHTML={{
            __html: highlightedSuggestion
          }}
        />
      </button>
    </li>
  );<commit_msg>trim input before comparing for highlight<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import escapeStringRegexp from 'escape-string-regexp';
import ArrowRightIcon from '../../../../public/images/icon-arrow-right.svg';

const AutoSuggestItem = (props) => {
  const { isActive, onSuggestionSelection, query, content } = props;
  const highlightedSuggestion = content.replace(
    new RegExp(`(${escapeStringRegexp(query.trim())})`, 'gi'),
    '<span class="c-auto-suggest__highlight">$1</span>'
  );

  return (
    <li>
      <button
        type="button"
        className={`c-auto-suggest-item ${isActive ? 'c-auto-suggest-item--active' : ''}`}
        onClick={onSuggestionSelection}
      >
        <span className="icon">
          <ArrowRightIcon />
        </span>
        <span
          // eslint-disable-next-line react/no-danger
          dangerouslySetInnerHTML={{
            __html: highlightedSuggestion
          }}
        />
      </button>
    </li>
  );
{'fraction_non_alphanumeric': 0.15255955397871263, 'fraction_numerical': 0.0010136847440446021, 'mean_word_length': 2.6353591160220993, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, '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': '7245534', 'n_tokens_mistral': 590, 'n_tokens_neox': 578, 'n_words': 111}