<commit_before>// @flow

import * as React from 'react'
import {Emoji, emojiIndex} from 'emoji-mart'

// Just the single set we use
import emojiSet from 'emoji-datasource-apple/img/apple/sheets/64.png'

import type {Props} from './emoji'

const backgroundImageFn = (set: string, sheetSize: string) => emojiSet

const skinToneRegex = /:([^:]*):(:skin-tone-\d:)?/i

const isValidEmoji = (fullEmoji: string) => {
  const parts = skinToneRegex.exec(fullEmoji)
  if (parts) {
    return !parts[1].startsWith('skin-tone') && emojiIndex.search(parts[1]).length > 0
  }
  return true
}
<commit_msg>ensure an exact match<commit_after>// @flow

import * as React from 'react'
import {Emoji, emojiIndex} from 'emoji-mart'

// Just the single set we use
import emojiSet from 'emoji-datasource-apple/img/apple/sheets/64.png'

import type {Props} from './emoji'

const backgroundImageFn = (set: string, sheetSize: string) => emojiSet

// Workaround for bug where if an invalid emoji name is supplied to Emoji,
// a full crash is triggered. Here we check the value between the first
// pair of colons & make sure it's not a skin-tone modifier and that we
// have a match for it in the emoji index
const emojiDataRegex = /:([^:]*):(:skin-tone-\d:)?/i
const isValidEmoji = (fullEmoji: string) => {
  const match = emojiDataRegex.exec(fullEmoji)
  if (match) {
    const id = match[1] && match[1].toLowerCase()
    const searchResults = emojiIndex.search(id)
    for (let emoji of searchResults) {
      if (emoji.id.toLowerCase() === id) {
        return true
      }
    }
  }
  return false
}

{'fraction_non_alphanumeric': 0.13434727503168567, 'fraction_numerical': 0.005703422053231939, 'mean_word_length': 3.7417417417417416, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '6425204', 'n_tokens_mistral': 539, 'n_tokens_neox': 552, 'n_words': 168}