summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/emoji/support/index.js
blob: 14b80be9b432f9c7f8d5e684d9c50da2f3fcf5b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import isEmojiUnicodeSupported from './is_emoji_unicode_supported';
import getUnicodeSupportMap from './unicode_support_map';

// cache browser support map between calls
let browserUnicodeSupportMap;

export default function isEmojiUnicodeSupportedByBrowser(emojiUnicode, unicodeVersion) {
  // Skipping the map creation for Bots + RSPec
  if (
    navigator.userAgent.indexOf('HeadlessChrome') > -1 ||
    navigator.userAgent.indexOf('Lighthouse') > -1 ||
    navigator.userAgent.indexOf('Speedindex') > -1
  ) {
    return true;
  }
  browserUnicodeSupportMap = browserUnicodeSupportMap || getUnicodeSupportMap();
  return isEmojiUnicodeSupported(browserUnicodeSupportMap, emojiUnicode, unicodeVersion);
}