Optimize url-preview image (#4216)

This commit is contained in:
MeiMei 2019-02-10 19:19:26 +09:00 committed by Acid Chicken (硫酸鶏)
parent af57b723a9
commit 95bbb190a6

View File

@ -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;
}