Emoji: Also accept regional indicators

This commit is contained in:
lain 2020-12-03 16:17:39 +01:00
parent a0aece3223
commit fa0d0b602f
2 changed files with 12 additions and 0 deletions

View file

@ -104,6 +104,11 @@ defp update_emojis(emojis) do
@external_resource "lib/pleroma/emoji-test.txt"
regional_indicators =
Enum.map(127_462..127_487, fn codepoint ->
<<codepoint::utf8>>
end)
emojis =
@external_resource
|> File.read!()
@ -125,6 +130,8 @@ defp update_emojis(emojis) do
end)
|> Enum.uniq()
emojis = emojis ++ regional_indicators
for emoji <- emojis do
def is_unicode_emoji?(unquote(emoji)), do: true
end

View file

@ -20,6 +20,11 @@ test "tells if a string is an unicode emoji" do
assert Emoji.is_unicode_emoji?("🤰")
assert Emoji.is_unicode_emoji?("❤️")
assert Emoji.is_unicode_emoji?("🏳️‍⚧️")
# Additionally, we accept regional indicators.
assert Emoji.is_unicode_emoji?("🇵")
assert Emoji.is_unicode_emoji?("🇴")
assert Emoji.is_unicode_emoji?("🇬")
end
end