From 769960f29e53e225761e3e119c6cc90137db9979 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Fri, 7 Sep 2018 02:26:31 +0900 Subject: [PATCH] Encode fetch URI if needed (#2649) --- src/services/drive/upload-from-url.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/services/drive/upload-from-url.ts b/src/services/drive/upload-from-url.ts index 0cf21ea5a2..35d4ec9883 100644 --- a/src/services/drive/upload-from-url.ts +++ b/src/services/drive/upload-from-url.ts @@ -34,8 +34,9 @@ export default async (url: string, user: IUser, folderId: mongodb.ObjectID = nul // write content at URL to temp file await new Promise((res, rej) => { const writable = fs.createWriteStream(path); + const requestUrl = URL.parse(url).pathname.match(/[^\u0021-\u00ff]/) ? encodeURI(url) : url; request({ - url, + url: requestUrl, headers: { 'User-Agent': config.user_agent }