From d261fdbbc0a35dc4ad88af0278d28db8baccec0e Mon Sep 17 00:00:00 2001 From: mei23 Date: Wed, 9 May 2018 20:14:34 +0900 Subject: [PATCH 1/2] Fix can't preview some url --- src/client/app/common/views/components/url-preview.vue | 2 +- src/server/web/url-preview.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/app/common/views/components/url-preview.vue b/src/client/app/common/views/components/url-preview.vue index c2dc07b41..3bae6e507 100644 --- a/src/client/app/common/views/components/url-preview.vue +++ b/src/client/app/common/views/components/url-preview.vue @@ -45,7 +45,7 @@ export default Vue.extend({ } else if (url.hostname == 'youtu.be') { this.youtubeId = url.pathname; } else { - fetch('/url?url=' + this.url).then(res => { + fetch('/url?url=' + encodeURIComponent(this.url)).then(res => { res.json().then(info => { this.title = info.title; this.description = info.description; diff --git a/src/server/web/url-preview.ts b/src/server/web/url-preview.ts index 8a5e934b1..041c475a4 100644 --- a/src/server/web/url-preview.ts +++ b/src/server/web/url-preview.ts @@ -16,6 +16,6 @@ function wrap(url: string): string { return url != null ? url.startsWith('https://') ? url - : `https://images.weserv.nl/?url=${url.replace(/^http:\/\//, '')}` + : `https://images.weserv.nl/?url=${encodeURIComponent(url.replace(/^http:\/\//, ''))}` : null; } From f40e1ff0cc793e60ae72bdc430c24e372cd86015 Mon Sep 17 00:00:00 2001 From: mei23 Date: Thu, 10 May 2018 01:08:33 +0900 Subject: [PATCH 2/2] Fix cause error in case preview has data URI --- src/server/web/url-preview.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/web/url-preview.ts b/src/server/web/url-preview.ts index 041c475a4..cd53837a2 100644 --- a/src/server/web/url-preview.ts +++ b/src/server/web/url-preview.ts @@ -14,7 +14,7 @@ module.exports = async (ctx: Koa.Context) => { function wrap(url: string): string { return url != null - ? url.startsWith('https://') + ? url.startsWith('https://') || url.startsWith('data:') ? url : `https://images.weserv.nl/?url=${encodeURIComponent(url.replace(/^http:\/\//, ''))}` : null;