mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 08:36:29 +00:00
Merge branch 'nil-bio-emojis' into 'develop'
add nil clause for Formatter.get_emoji/1 to return an empty result Closes #274 See merge request pleroma/pleroma!315
This commit is contained in:
commit
7ca2a2ddea
2 changed files with 13 additions and 1 deletions
|
@ -158,10 +158,12 @@ defmodule Pleroma.Formatter do
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_emoji(text) do
|
def get_emoji(text) when is_binary(text) do
|
||||||
Enum.filter(@emoji, fn {emoji, _} -> String.contains?(text, ":#{emoji}:") end)
|
Enum.filter(@emoji, fn {emoji, _} -> String.contains?(text, ":#{emoji}:") end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_emoji(_), do: []
|
||||||
|
|
||||||
def get_custom_emoji() do
|
def get_custom_emoji() do
|
||||||
@emoji
|
@emoji
|
||||||
end
|
end
|
||||||
|
|
|
@ -214,4 +214,14 @@ defmodule Pleroma.FormatterTest do
|
||||||
|
|
||||||
assert Formatter.get_emoji(text) == [{"moominmamma", "/finmoji/128px/moominmamma-128.png"}]
|
assert Formatter.get_emoji(text) == [{"moominmamma", "/finmoji/128px/moominmamma-128.png"}]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it returns a nice empty result when no emojis are present" do
|
||||||
|
text = "I love moominamma"
|
||||||
|
assert Formatter.get_emoji(text) == []
|
||||||
|
end
|
||||||
|
|
||||||
|
test "it doesn't die when text is absent" do
|
||||||
|
text = nil
|
||||||
|
assert Formatter.get_emoji(text) == []
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue