1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-12-02 00:38:14 +09:00

Encode fetch URI if needed (#2649)

This commit is contained in:
MeiMei 2018-09-07 02:26:31 +09:00 committed by syuilo
parent d92e9759f3
commit 769960f29e

View File

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