mirror of
https://github.com/misskey-dev/summerflare.git
synced 2025-04-29 02:37:17 +09:00
test: check upstream content-type
This commit is contained in:
parent
79d0dafaa2
commit
eaeb855fa9
31
src/index.ts
31
src/index.ts
@ -50,6 +50,7 @@ if (import.meta.vitest) {
|
|||||||
[
|
[
|
||||||
"the simple UTF-8 encoded website",
|
"the simple UTF-8 encoded website",
|
||||||
"https://example.com/",
|
"https://example.com/",
|
||||||
|
"text/html; charset=UTF-8",
|
||||||
{
|
{
|
||||||
title: "Example Domain",
|
title: "Example Domain",
|
||||||
thumbnail: null,
|
thumbnail: null,
|
||||||
@ -70,6 +71,7 @@ if (import.meta.vitest) {
|
|||||||
[
|
[
|
||||||
"the simple Shift_JIS encoded website",
|
"the simple Shift_JIS encoded website",
|
||||||
"http://abehiroshi.la.coocan.jp/",
|
"http://abehiroshi.la.coocan.jp/",
|
||||||
|
"text/html",
|
||||||
{
|
{
|
||||||
title: "阿部寛のホームページ",
|
title: "阿部寛のホームページ",
|
||||||
thumbnail: null,
|
thumbnail: null,
|
||||||
@ -90,6 +92,7 @@ if (import.meta.vitest) {
|
|||||||
[
|
[
|
||||||
"the simple EUC-JP encoded website",
|
"the simple EUC-JP encoded website",
|
||||||
"https://www.postgresql.jp/document/pg632doc/tutorial/f01.htm",
|
"https://www.postgresql.jp/document/pg632doc/tutorial/f01.htm",
|
||||||
|
"text/html; charset=EUC-JP",
|
||||||
{
|
{
|
||||||
title: "概要",
|
title: "概要",
|
||||||
thumbnail: null,
|
thumbnail: null,
|
||||||
@ -110,6 +113,7 @@ if (import.meta.vitest) {
|
|||||||
[
|
[
|
||||||
"the Shift_JIS encoded website with thumbnail",
|
"the Shift_JIS encoded website with thumbnail",
|
||||||
"https://store.shochiku.co.jp/shop/g/g23080501/",
|
"https://store.shochiku.co.jp/shop/g/g23080501/",
|
||||||
|
"text/html; charset=shift_jis",
|
||||||
{
|
{
|
||||||
title: "アイドルマスター ミリオンライブ! 第1幕 パンフレット",
|
title: "アイドルマスター ミリオンライブ! 第1幕 パンフレット",
|
||||||
thumbnail: "https://store.shochiku.co.jp/img/goods/S/23080501s.jpg",
|
thumbnail: "https://store.shochiku.co.jp/img/goods/S/23080501s.jpg",
|
||||||
@ -127,9 +131,31 @@ if (import.meta.vitest) {
|
|||||||
url: "https://store.shochiku.co.jp/shop/g/g23080501/",
|
url: "https://store.shochiku.co.jp/shop/g/g23080501/",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"the EUC-JP encoded website with thumbnail",
|
||||||
|
"https://news.livedoor.com/article/detail/24612811/",
|
||||||
|
"text/html; charset=euc-jp",
|
||||||
|
{
|
||||||
|
description: "コミッションサービス「Skeb」を提供するSkebは7月14日、Twitterに投稿する形で、分散型SNS「Misskey」のスポンサーになったと発表した。Skebが分散型SNS「Misskey」のスポンサーに!Misskeyとは、分散型プロトコル",
|
||||||
|
icon: "https://parts.news.livedoor.com/img/favicon.ico?20230601",
|
||||||
|
large: true,
|
||||||
|
player: {
|
||||||
|
allow: [],
|
||||||
|
height: null,
|
||||||
|
url: null,
|
||||||
|
width: null,
|
||||||
|
},
|
||||||
|
sensitive: false,
|
||||||
|
sitename: "ライブドアニュース",
|
||||||
|
thumbnail: "https://image.news.livedoor.com/newsimage/stf/5/4/54209_1223_0ecb92105835b40f6ff567ce15c8e39e.jpg",
|
||||||
|
title: "Skebが分散型SNS「Misskey」のスポンサーに!",
|
||||||
|
url: "https://news.livedoor.com/article/detail/24612811/",
|
||||||
|
},
|
||||||
|
],
|
||||||
[
|
[
|
||||||
"the UTF-8 encoded website with oEmbed",
|
"the UTF-8 encoded website with oEmbed",
|
||||||
"https://open.spotify.com/intl-ja/track/5Odr16TvEN4my22K9nbH7l",
|
"https://open.spotify.com/intl-ja/track/5Odr16TvEN4my22K9nbH7l",
|
||||||
|
"text/html; charset=utf-8",
|
||||||
{
|
{
|
||||||
description: "May'n · Song · 2012",
|
description: "May'n · Song · 2012",
|
||||||
icon: "https://open.spotifycdn.com/cdn/images/favicon.0f31d2ea.ico",
|
icon: "https://open.spotifycdn.com/cdn/images/favicon.0f31d2ea.ico",
|
||||||
@ -147,9 +173,12 @@ if (import.meta.vitest) {
|
|||||||
url: "https://open.spotify.com/track/5Odr16TvEN4my22K9nbH7l",
|
url: "https://open.spotify.com/track/5Odr16TvEN4my22K9nbH7l",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
])("should return summary of %s <%s>", async (_, url, expected) => {
|
])("should return summary of %s <%s>", async (_, url, contentType, expected) => {
|
||||||
const request = new Request(`https://fakehost/url?${new URLSearchParams({ url })}`)
|
const request = new Request(`https://fakehost/url?${new URLSearchParams({ url })}`)
|
||||||
const ctx = createExecutionContext()
|
const ctx = createExecutionContext()
|
||||||
|
const preconnect = await fetch(url, fetchOptions)
|
||||||
|
expect(preconnect.status).toBe(200)
|
||||||
|
expect(preconnect.headers.get("content-type")).toBe(contentType)
|
||||||
const response = await app.fetch(request, env, ctx)
|
const response = await app.fetch(request, env, ctx)
|
||||||
await waitOnExecutionContext(ctx)
|
await waitOnExecutionContext(ctx)
|
||||||
expect(response.status).toBe(200)
|
expect(response.status).toBe(200)
|
||||||
|
@ -14,7 +14,7 @@ export default function general(url: URL, html: HTMLRewriter) {
|
|||||||
const image = getImage(url, html)
|
const image = getImage(url, html)
|
||||||
const player = Promise.all([card, getPlayer(url, html)]).then<Player>(([card, parsedPlayer]) => {
|
const player = Promise.all([card, getPlayer(url, html)]).then<Player>(([card, parsedPlayer]) => {
|
||||||
return {
|
return {
|
||||||
url: card !== "summary_large_image" && parsedPlayer.urlGeneral || parsedPlayer.urlCommon,
|
url: (card !== "summary_large_image" && parsedPlayer.urlGeneral) || parsedPlayer.urlCommon,
|
||||||
width: parsedPlayer.width,
|
width: parsedPlayer.width,
|
||||||
height: parsedPlayer.height,
|
height: parsedPlayer.height,
|
||||||
allow: parsedPlayer.allow,
|
allow: parsedPlayer.allow,
|
||||||
|
@ -103,7 +103,7 @@ export default function getPlayerOEmbed(url: URL, html: HTMLRewriter) {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "text/html; charset=UTF-8",
|
"Content-Type": "text/html; charset=UTF-8",
|
||||||
},
|
},
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
.body?.getReader()
|
.body?.getReader()
|
||||||
while (reader != null && !(await reader.read()).done);
|
while (reader != null && !(await reader.read()).done);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
name = "summerflare"
|
name = "summerflare"
|
||||||
main = "src/index.ts"
|
main = "src/index.ts"
|
||||||
compatibility_date = "2024-05-13"
|
compatibility_date = "2024-04-04"
|
||||||
compatibility_flags = ["nodejs_compat"]
|
compatibility_flags = ["nodejs_compat"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user