aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-08 14:49:15 +0200
committerChocobozzz <me@florianbigard.com>2021-10-11 09:37:26 +0200
commite93ee8382595dc291d79f43cab492d0e4c9b8e20 (patch)
treef9ce5f5e25501c9dd7e29f48a4242f966e2a7fc5 /server/middlewares
parentdb9df9a72c67a6ba150620f0f1c0838a3c155786 (diff)
downloadPeerTube-e93ee8382595dc291d79f43cab492d0e4c9b8e20.tar.gz
PeerTube-e93ee8382595dc291d79f43cab492d0e4c9b8e20.tar.zst
PeerTube-e93ee8382595dc291d79f43cab492d0e4c9b8e20.zip
Handle oembed with params in URL
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/oembed.ts16
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({