From d2422c2b896c2dea0697d0b972219704ef1aaf62 Mon Sep 17 00:00:00 2001 From: niyari Date: Tue, 10 Jan 2023 04:59:17 +0900 Subject: [PATCH] =?utf8?q?twitter=20/=20twemoji=20=E3=81=AECDN=E3=82=92?= =?utf8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- OpenTween.Tests/TweetExtractorTest.cs | 28 ++++++++++++++-------------- OpenTween.Tests/TweetFormatterTest.cs | 4 ++-- OpenTween/TweetExtractor.cs | 3 ++- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/OpenTween.Tests/TweetExtractorTest.cs b/OpenTween.Tests/TweetExtractorTest.cs index 942440d4..29aa41ec 100644 --- a/OpenTween.Tests/TweetExtractorTest.cs +++ b/OpenTween.Tests/TweetExtractorTest.cs @@ -191,7 +191,7 @@ namespace OpenTween Assert.Equal(new[] { 5, 6 }, entity.Indices); Assert.Equal("✨", entity.Text); - Assert.Equal("https://twemoji.maxcdn.com/2/72x72/2728.png", entity.Url); + Assert.Equal("https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/2728.png", entity.Url); } [Fact] @@ -202,7 +202,7 @@ namespace OpenTween // 「𠮷」「🍚」は UTF-16 でそれぞれ 2byte になるがインデックスはコードポイント単位で数えなければならない Assert.Equal(new[] { 4, 5 }, entity.Indices); Assert.Equal("🍚", entity.Text); - Assert.Equal("https://twemoji.maxcdn.com/2/72x72/1f35a.png", entity.Url); + Assert.Equal("https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/1f35a.png", entity.Url); } [Fact] @@ -224,7 +224,7 @@ namespace OpenTween Assert.Equal(new[] { 0, 2 }, entity.Indices); Assert.Equal("©", entity.Text); - Assert.Equal("https://twemoji.maxcdn.com/2/72x72/a9.png", entity.Url); + Assert.Equal("https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/a9.png", entity.Url); } [Fact] @@ -238,7 +238,7 @@ namespace OpenTween 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("https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/1f363.png", entities[0].Url); Assert.Equal(new[] { 1, 2 }, entities[1].Indices); Assert.Equal("", entities[1].Text); @@ -253,7 +253,7 @@ namespace OpenTween Assert.Equal(new[] { 0, 2 }, entity.Indices); Assert.Equal("#⃣", entity.Text); - Assert.Equal("https://twemoji.maxcdn.com/2/72x72/23-20e3.png", entity.Url); + Assert.Equal("https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/23-20e3.png", entity.Url); } [Fact] @@ -265,7 +265,7 @@ namespace OpenTween Assert.Equal(new[] { 0, 1 }, entity.Indices); Assert.Equal("🦒", entity.Text); - Assert.Equal("https://twemoji.maxcdn.com/2/72x72/1f992.png", entity.Url); + Assert.Equal("https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/1f992.png", entity.Url); } [Fact] @@ -277,7 +277,7 @@ namespace OpenTween Assert.Equal(new[] { 0, 1 }, entity.Indices); Assert.Equal("🦸", entity.Text); - Assert.Equal("https://twemoji.maxcdn.com/2/72x72/1f9b8.png", entity.Url); + Assert.Equal("https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/1f9b8.png", entity.Url); } [Fact] @@ -289,7 +289,7 @@ namespace OpenTween Assert.Equal(new[] { 0, 1 }, entity.Indices); Assert.Equal("🧅", entity.Text); - Assert.Equal("https://twemoji.maxcdn.com/2/72x72/1f9c5.png", entity.Url); + Assert.Equal("https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/1f9c5.png", entity.Url); } [Fact] @@ -301,7 +301,7 @@ namespace OpenTween Assert.Equal(new[] { 0, 1 }, entity.Indices); Assert.Equal("🥷", entity.Text); - Assert.Equal("https://twemoji.maxcdn.com/2/72x72/1f977.png", entity.Url); + Assert.Equal("https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/1f977.png", entity.Url); } [Fact] @@ -313,7 +313,7 @@ namespace OpenTween Assert.Equal(new[] { 0, 1 }, entity.Indices); Assert.Equal("🫠", entity.Text); - Assert.Equal("https://twemoji.maxcdn.com/2/72x72/1fae0.png", entity.Url); + Assert.Equal("https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/1fae0.png", entity.Url); } [Fact] @@ -325,7 +325,7 @@ namespace OpenTween Assert.Equal(new[] { 0, 2 }, entity.Indices); Assert.Equal("👦\U0001F3FF", entity.Text); - Assert.Equal("https://twemoji.maxcdn.com/2/72x72/1f466-1f3ff.png", entity.Url); + Assert.Equal("https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/1f466-1f3ff.png", entity.Url); } [Fact] @@ -337,7 +337,7 @@ namespace OpenTween Assert.Equal(new[] { 0, 1 }, entity.Indices); Assert.Equal("\U0001F3FF", entity.Text); - Assert.Equal("https://twemoji.maxcdn.com/2/72x72/1f3ff.png", entity.Url); + Assert.Equal("https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/1f3ff.png", entity.Url); } [Fact] @@ -349,7 +349,7 @@ namespace OpenTween Assert.Equal(new[] { 0, 3 }, entity.Indices); Assert.Equal("👨\u200D🎨", entity.Text); - Assert.Equal("https://twemoji.maxcdn.com/2/72x72/1f468-200d-1f3a8.png", entity.Url); + Assert.Equal("https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/1f468-200d-1f3a8.png", entity.Url); } [Fact] @@ -362,7 +362,7 @@ namespace OpenTween Assert.Equal(new[] { 0, 4 }, entity.Indices); Assert.Equal("🏃\u200D♀\uFE0F", entity.Text); - Assert.Equal("https://twemoji.maxcdn.com/2/72x72/1f3c3-200d-2640-fe0f.png", entity.Url); + Assert.Equal("https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/1f3c3-200d-2640-fe0f.png", entity.Url); } } } diff --git a/OpenTween.Tests/TweetFormatterTest.cs b/OpenTween.Tests/TweetFormatterTest.cs index c8c8ebaa..8902c96a 100644 --- a/OpenTween.Tests/TweetFormatterTest.cs +++ b/OpenTween.Tests/TweetFormatterTest.cs @@ -175,11 +175,11 @@ namespace OpenTween { Indices = new[] { 0, 1 }, Text = "🍣", - Url = "https://twemoji.maxcdn.com/2/72x72/1f363.png", + Url = "https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/1f363.png", }, }; - var expected = "\"🍣\""; + var expected = "\"🍣\""; Assert.Equal(expected, TweetFormatter.AutoLinkHtml(text, entities)); } diff --git a/OpenTween/TweetExtractor.cs b/OpenTween/TweetExtractor.cs index da822153..df1cf25a 100644 --- a/OpenTween/TweetExtractor.cs +++ b/OpenTween/TweetExtractor.cs @@ -189,7 +189,8 @@ namespace OpenTween { Indices = new[] { startPos, endPos }, Text = input, - Url = "https://twemoji.maxcdn.com/2/72x72/" + string.Join("-", codepointHex) + ".png", + // TODO: CDN(MaxCDN)の廃止のため一時的に変更。 https://twemoji.maxcdn.com/2/72x72/ + Url = "https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/72x72/" + string.Join("-", codepointHex) + ".png", }; } else -- 2.11.0