From 2c987d5c39f06ad17f911465aedd430eb664f210 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sat, 13 Mar 2021 23:22:54 +0900 Subject: [PATCH] Fix assets test and favicon type (#7344) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix * koa-faviconはimage/x-iconがデフォルトらしい * シンプルに * faviconなど --- assets/favicon.ico | 3 +++ locales/ja-JP.yml | 2 +- src/server/web/index.ts | 2 +- test/fetch-resource.ts | 19 +++++++++++++------ test/utils.ts | 2 +- 5 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 assets/favicon.ico diff --git a/assets/favicon.ico b/assets/favicon.ico new file mode 100644 index 000000000..d52a6d920 --- /dev/null +++ b/assets/favicon.ico @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:11ddf9107e7ea6edb8fcbb0126a69175ebb45ec1f56b2ab00eb3dbc9acc4c0e8 +size 90022 diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index e5700fe05..5729da8da 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -322,7 +322,7 @@ proxyRemoteFilesDescription: "この設定を有効にすると、未保存ま driveCapacityPerLocalAccount: "ローカルユーザーひとりあたりのドライブ容量" driveCapacityPerRemoteAccount: "リモートユーザーひとりあたりのドライブ容量" inMb: "メガバイト単位" -iconUrl: "アイコン画像のURL" +iconUrl: "アイコン画像のURL (faviconなど)" bannerUrl: "バナー画像のURL" basicInfo: "基本情報" pinnedUsers: "ピン留めユーザー" diff --git a/src/server/web/index.ts b/src/server/web/index.ts index 7b087bbf5..ea356206f 100644 --- a/src/server/web/index.ts +++ b/src/server/web/index.ts @@ -45,7 +45,7 @@ app.use(views(__dirname + '/views', { })); // Serve favicon -app.use(favicon(`${__dirname}/../../../assets/favicon.png`)); +app.use(favicon(`${__dirname}/../../../assets/favicon.ico`)); // Common request handler app.use(async (ctx, next) => { diff --git a/test/fetch-resource.ts b/test/fetch-resource.ts index bd3a325dc..12a37b6cb 100644 --- a/test/fetch-resource.ts +++ b/test/fetch-resource.ts @@ -22,6 +22,7 @@ const UNSPECIFIED = '*/*'; // Response Contet-Type const AP = 'application/activity+json; charset=utf-8'; +const JSON = 'application/json; charset=utf-8'; const HTML = 'text/html; charset=utf-8'; describe('Fetch resource', () => { @@ -50,33 +51,39 @@ describe('Fetch resource', () => { })); it('GET root', async(async () => { - const res = await simpleGet('/', 'text/html'); + const res = await simpleGet('/'); assert.strictEqual(res.status, 200); + assert.strictEqual(res.type, HTML); })); it('GET docs', async(async () => { - const res = await simpleGet('/docs/ja-JP/about', 'text/html'); + const res = await simpleGet('/docs/ja-JP/about'); assert.strictEqual(res.status, 200); + assert.strictEqual(res.type, HTML); })); it('GET api-doc', async(async () => { - const res = await simpleGet('/api-doc', 'text/html'); + const res = await simpleGet('/api-doc'); assert.strictEqual(res.status, 200); + assert.strictEqual(res.type, HTML); })); it('GET api.json', async(async () => { - const res = await simpleGet('/api.json', 'application/json'); + const res = await simpleGet('/api.json'); assert.strictEqual(res.status, 200); + assert.strictEqual(res.type, JSON); })); it('GET favicon.ico', async(async () => { - const res = await simpleGet('/favicon.ico', 'image/png'); + const res = await simpleGet('/favicon.ico'); assert.strictEqual(res.status, 200); + assert.strictEqual(res.type, 'image/x-icon'); })); it('GET apple-touch-icon.png', async(async () => { - const res = await simpleGet('/apple-touch-icon.png', 'image/png'); + const res = await simpleGet('/apple-touch-icon.png'); assert.strictEqual(res.status, 200); + assert.strictEqual(res.type, 'image/png'); })); }); diff --git a/test/utils.ts b/test/utils.ts index 55e877a8a..b0393ee19 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -110,7 +110,7 @@ export function connectStream(user: any, channel: string, listener: (message: Re }); } -export const simpleGet = async (path: string, accept: string): Promise<{ status?: number, type?: string, location?: string }> => { +export const simpleGet = async (path: string, accept = '*/*'): Promise<{ status?: number, type?: string, location?: string }> => { // node-fetchだと3xxを取れない return await new Promise((resolve, reject) => { const req = http.request(`http://localhost:${port}${path}`, {