diff options
author | Chocobozzz <me@florianbigard.com> | 2021-10-08 14:49:15 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-10-08 14:49:15 +0200 |
commit | 7d786e5c1621e1aa41db1d6e7244f16df7343d45 (patch) | |
tree | f54a79cae5aa7d48bcbb102b2b8259936d3b3096 /server/middlewares/validators | |
parent | dd0ad8dfa5a4cdab066602668ed182cb45098e10 (diff) | |
download | PeerTube-7d786e5c1621e1aa41db1d6e7244f16df7343d45.tar.gz PeerTube-7d786e5c1621e1aa41db1d6e7244f16df7343d45.tar.zst PeerTube-7d786e5c1621e1aa41db1d6e7244f16df7343d45.zip |
Handle oembed with params in URL
Diffstat (limited to 'server/middlewares/validators')
-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({ |