From e93ee8382595dc291d79f43cab492d0e4c9b8e20 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 8 Oct 2021 14:49:15 +0200 Subject: Handle oembed with params in URL --- server/middlewares/validators/oembed.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'server/middlewares/validators/oembed.ts') diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts index 5e47211b5..96c8adc99 100644 --- a/server/middlewares/validators/oembed.ts +++ b/server/middlewares/validators/oembed.ts @@ -62,12 +62,26 @@ const oembedValidator = [ const url = req.query.url as string + let urlPath: string + + try { + urlPath = new URL(url).pathname + } catch (err) { + return res.fail({ + status: HttpStatusCode.BAD_REQUEST_400, + message: err.message, + data: { + url + } + }) + } + const isPlaylist = startPlaylistURLs.some(u => url.startsWith(u)) const isVideo = isPlaylist ? false : startVideoURLs.some(u => url.startsWith(u)) const startIsOk = isVideo || isPlaylist - const matches = watchRegex.exec(url) + const matches = watchRegex.exec(urlPath) if (startIsOk === false || matches === null) { return res.fail({ -- cgit v1.2.3