}
[Fact]
+ public void ExtractEmojiEntities_VariationSelector_UnnecessaryEmojiStyleTest()
+ {
+ // 余分な U+FE0F が付いている場合
+ var origText = "🍣\uFE0F"; // U+1F363 + U+FE0F (emoji style)
+ var entities = TweetExtractor.ExtractEmojiEntities(origText).ToArray();
+
+ Assert.Equal(2, entities.Length);
+
+ Assert.Equal(new[] { 0, 1 }, entities[0].Indices);
+ Assert.Equal("🍣", entities[0].Text);
+ Assert.Equal("https://twemoji.maxcdn.com/2/72x72/1f363.png", entities[0].Url);
+
+ Assert.Equal(new[] { 1, 2 }, entities[1].Indices);
+ Assert.Equal("", entities[1].Text);
+ Assert.Equal("", entities[1].Url);
+ }
+
+ [Fact]
public void ExtractEmojiEntities_CombiningCharacterTest()
{
var origText = "#⃣"; // U+0023 U+20E3 (合字)
Assert.Equal(expected, TweetFormatter.AutoLinkHtml(text, entities));
}
-
[Fact]
public void FormatEmojiEntity_Test()
{
var expected = "<img class=\"emoji\" src=\"https://twemoji.maxcdn.com/2/72x72/1f363.png\" alt=\"🍣\" />";
Assert.Equal(expected, TweetFormatter.AutoLinkHtml(text, entities));
}
+
+ [Fact]
+ public void FormatEmojiEntity_EmptyUrlTest()
+ {
+ // 余分な U+FE0F があった場合に Url が空の絵文字エンティティが渡される
+ var text = "\uFE0F";
+ var entities = new[]
+ {
+ new TwitterEntityEmoji
+ {
+ Indices = new[] { 0, 1 },
+ Text = "",
+ Url = "",
+ },
+ };
+
+ var expected = "";
+ Assert.Equal(expected, TweetFormatter.AutoLinkHtml(text, entities));
+ }
+
[Fact]
public void AutoLinkHtml_EntityNullTest()
{
==== Ver 2.3.2-dev(2019/xx/xx)
* CHG: htn.to の短縮URLを展開する際に強制的にHTTPSを使用する
+ * FIX: Twemojiを有効にすると絵文字の後に余分な文字が表示される場合がある不具合を修正
==== Ver 2.3.1(2019/04/22)
* FIX: 2019/5/20に予定されているTwitter APIの仕様変更によりエラーが発生する問題を修正
var startPos = text.GetCodepointCount(0, match.Index);
var endPos = startPos + text.GetCodepointCount(match.Index, match.Index + match.Length);
- yield return new TwitterEntityEmoji
+ TwitterEntityEmoji entity;
+ if (codepointHex.Count >= 1)
{
- Indices = new[] { startPos, endPos },
- Text = input,
- Url = "https://twemoji.maxcdn.com/2/72x72/" + string.Join("-", codepointHex) + ".png",
- };
+ entity = new TwitterEntityEmoji
+ {
+ Indices = new[] { startPos, endPos },
+ Text = input,
+ Url = "https://twemoji.maxcdn.com/2/72x72/" + string.Join("-", codepointHex) + ".png",
+ };
+ }
+ else
+ {
+ entity = new TwitterEntityEmoji
+ {
+ Indices = new[] { startPos, endPos },
+ Text = input,
+ Url = "",
+ };
+ }
+
+ yield return entity;
}
}
}
if (!SettingManager.Local.UseTwemoji)
return t(e(targetText));
+ if (string.IsNullOrEmpty(entity.Url))
+ return "";
+
return "<img class=\"emoji\" src=\"" + e(entity.Url) + "\" alt=\"" + e(entity.Text) + "\" />";
}