]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/oembed.ts
Add migrations
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / oembed.ts
index c89bc26de8ae24ce2275971bdefee5bbd33f33ac..ab4dbb4d1814438b33b7821b9bcb11993ed02b0f 100644 (file)
@@ -1,14 +1,14 @@
 import * as express from 'express'
-import { query } from 'express-validator/check'
+import { query } from 'express-validator'
 import { join } from 'path'
 import { isTestInstance } from '../../helpers/core-utils'
 import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
-import { doesVideoExist } from '../../helpers/custom-validators/videos'
 import { logger } from '../../helpers/logger'
-import { CONFIG } from '../../initializers'
 import { areValidationErrors } from './utils'
+import { WEBSERVER } from '../../initializers/constants'
+import { doesVideoExist } from '../../helpers/middlewares'
 
-const urlShouldStartWith = CONFIG.WEBSERVER.SCHEME + '://' + join(CONFIG.WEBSERVER.HOST, 'videos', 'watch') + '/'
+const urlShouldStartWith = WEBSERVER.SCHEME + '://' + join(WEBSERVER.HOST, 'videos', 'watch') + '/'
 const videoWatchRegex = new RegExp('([^/]+)$')
 const isURLOptions = {
   require_host: true,
@@ -37,8 +37,11 @@ const oembedValidator = [
                 .end()
     }
 
-    const startIsOk = req.query.url.startsWith(urlShouldStartWith)
-    const matches = videoWatchRegex.exec(req.query.url)
+    const url = req.query.url as string
+
+    const startIsOk = url.startsWith(urlShouldStartWith)
+    const matches = videoWatchRegex.exec(url)
+
     if (startIsOk === false || matches === null) {
       return res.status(400)
                 .json({ error: 'Invalid url.' })