diff options
-rw-r--r-- | server/middlewares/validators/oembed.ts | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts index cbd645a71..32dd05271 100644 --- a/server/middlewares/validators/oembed.ts +++ b/server/middlewares/validators/oembed.ts | |||
@@ -28,7 +28,6 @@ function buildUrls (paths: string[]) { | |||
28 | const startPlaylistURLs = buildUrls(playlistPaths) | 28 | const startPlaylistURLs = buildUrls(playlistPaths) |
29 | const startVideoURLs = buildUrls(videoPaths) | 29 | const startVideoURLs = buildUrls(videoPaths) |
30 | 30 | ||
31 | const watchRegex = /\/([^/]+)$/ | ||
32 | const isURLOptions = { | 31 | const isURLOptions = { |
33 | require_host: true, | 32 | require_host: true, |
34 | require_tld: true | 33 | require_tld: true |
@@ -81,9 +80,9 @@ const oembedValidator = [ | |||
81 | 80 | ||
82 | const startIsOk = isVideo || isPlaylist | 81 | const startIsOk = isVideo || isPlaylist |
83 | 82 | ||
84 | const matches = watchRegex.exec(urlPath) | 83 | const parts = urlPath.split('/') |
85 | 84 | ||
86 | if (startIsOk === false || matches === null) { | 85 | if (startIsOk === false || parts.length === 0) { |
87 | return res.fail({ | 86 | return res.fail({ |
88 | status: HttpStatusCode.BAD_REQUEST_400, | 87 | status: HttpStatusCode.BAD_REQUEST_400, |
89 | message: 'Invalid url.', | 88 | message: 'Invalid url.', |
@@ -93,7 +92,7 @@ const oembedValidator = [ | |||
93 | }) | 92 | }) |
94 | } | 93 | } |
95 | 94 | ||
96 | const elementId = toCompleteUUID(matches[1]) | 95 | const elementId = toCompleteUUID(parts.pop()) |
97 | if (isIdOrUUIDValid(elementId) === false) { | 96 | if (isIdOrUUIDValid(elementId) === false) { |
98 | return res.fail({ message: 'Invalid video or playlist id.' }) | 97 | return res.fail({ message: 'Invalid video or playlist id.' }) |
99 | } | 98 | } |