From 95bbb190a6e472340e9730c256de656462d9dd4d Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sun, 10 Feb 2019 19:19:26 +0900 Subject: [PATCH] Optimize url-preview image (#4216) --- src/server/web/url-preview.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server/web/url-preview.ts b/src/server/web/url-preview.ts index 4cda5ecb0..dad27d9a9 100644 --- a/src/server/web/url-preview.ts +++ b/src/server/web/url-preview.ts @@ -33,8 +33,8 @@ module.exports = async (ctx: Koa.BaseContext) => { function wrap(url: string): string { return url != null - ? url.startsWith('https://') || url.startsWith('data:') - ? url - : `https://images.weserv.nl/?url=${encodeURIComponent(url.replace(/^http:\/\//, ''))}` + ? url.match(/^https?:\/\//) + ? `https://images.weserv.nl/?url=${encodeURIComponent(url.replace(/^http:\/\//, '').replace(/^https:\/\//, 'ssl:'))}&w=200&h=200` + : url : null; }