]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/pods.js
Server: use binary data instead of base64 to send thumbnails
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / pods.js
index 28d04a05dc02ac2923bca5b2e3c5c9701f663bbf..8bb3733ffae4465afd4eac17131b1f288c695cba 100644 (file)
@@ -5,14 +5,19 @@ const validator = require('express-validator').validator
 const miscValidators = require('./misc')
 
 const podsValidators = {
-  isEachUniqueUrlValid: isEachUniqueUrlValid
+  isEachUniqueHostValid,
+  isHostValid
 }
 
-function isEachUniqueUrlValid (urls) {
-  return miscValidators.isArray(urls) &&
-    urls.length !== 0 &&
-    urls.every(function (url) {
-      return validator.isURL(url) && urls.indexOf(url) === urls.lastIndexOf(url)
+function isHostValid (host) {
+  return validator.isURL(host) && host.split('://').length === 1
+}
+
+function isEachUniqueHostValid (hosts) {
+  return miscValidators.isArray(hosts) &&
+    hosts.length !== 0 &&
+    hosts.every(function (host) {
+      return isHostValid(host) && hosts.indexOf(host) === hosts.lastIndexOf(host)
     })
 }