diff options
Diffstat (limited to 'server/middlewares/validators/oembed.ts')
-rw-r--r-- | server/middlewares/validators/oembed.ts | 16 |
1 files changed, 15 insertions, 1 deletions
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 = [ | |||
62 | 62 | ||
63 | const url = req.query.url as string | 63 | const url = req.query.url as string |
64 | 64 | ||
65 | let urlPath: string | ||
66 | |||
67 | try { | ||
68 | urlPath = new URL(url).pathname | ||
69 | } catch (err) { | ||
70 | return res.fail({ | ||
71 | status: HttpStatusCode.BAD_REQUEST_400, | ||
72 | message: err.message, | ||
73 | data: { | ||
74 | url | ||
75 | } | ||
76 | }) | ||
77 | } | ||
78 | |||
65 | const isPlaylist = startPlaylistURLs.some(u => url.startsWith(u)) | 79 | const isPlaylist = startPlaylistURLs.some(u => url.startsWith(u)) |
66 | const isVideo = isPlaylist ? false : startVideoURLs.some(u => url.startsWith(u)) | 80 | const isVideo = isPlaylist ? false : startVideoURLs.some(u => url.startsWith(u)) |
67 | 81 | ||
68 | const startIsOk = isVideo || isPlaylist | 82 | const startIsOk = isVideo || isPlaylist |
69 | 83 | ||
70 | const matches = watchRegex.exec(url) | 84 | const matches = watchRegex.exec(urlPath) |
71 | 85 | ||
72 | if (startIsOk === false || matches === null) { | 86 | if (startIsOk === false || matches === null) { |
73 | return res.fail({ | 87 | return res.fail({ |