From 763592ce2070852b7eea49326ca63e223f922be1 Mon Sep 17 00:00:00 2001 From: Ibrahim Ansari Date: Sun, 17 Oct 2021 02:16:16 +0530 Subject: [PATCH] [backport] fix /ocr on newer Node versions --- server/bot/imports/tools.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/bot/imports/tools.ts b/server/bot/imports/tools.ts index 7fb4c26..d331df2 100644 --- a/server/bot/imports/tools.ts +++ b/server/bot/imports/tools.ts @@ -1,6 +1,6 @@ import https from 'https' import { get } from 'http' -import { parse } from 'url' +import { URL } from 'url' import { Db } from 'mongodb' import { Message } from 'eris' @@ -78,8 +78,8 @@ export const fetchLimited = async (url: string, limit: number, opts = {}): Promi return new Promise((resolve, reject) => { let size = 0 const data: Buffer[] = [] - const parsedUrl = parse(url) - const req = (parsedUrl.protocol === 'https:' ? https.get : get)({ ...parse(url), ...opts }, (res) => { + const parsedUrl = new URL(url) + const req = (parsedUrl.protocol === 'https:' ? https.get : get)(parsedUrl, opts, (res) => { if (!isNaN(+res.headers['content-length']) && +res.headers['content-length'] > byteLimit) { req.abort() resolve(false)