diff options
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/pods.js | 12 | ||||
-rw-r--r-- | server/helpers/custom-validators/videos.js | 6 | ||||
-rw-r--r-- | server/helpers/requests.js | 8 |
3 files changed, 14 insertions, 12 deletions
diff --git a/server/helpers/custom-validators/pods.js b/server/helpers/custom-validators/pods.js index 40f8b5d0b..0154a2424 100644 --- a/server/helpers/custom-validators/pods.js +++ b/server/helpers/custom-validators/pods.js | |||
@@ -5,14 +5,14 @@ const validator = require('express-validator').validator | |||
5 | const miscValidators = require('./misc') | 5 | const miscValidators = require('./misc') |
6 | 6 | ||
7 | const podsValidators = { | 7 | const podsValidators = { |
8 | isEachUniqueUrlValid | 8 | isEachUniqueHostValid |
9 | } | 9 | } |
10 | 10 | ||
11 | function isEachUniqueUrlValid (urls) { | 11 | function isEachUniqueHostValid (hosts) { |
12 | return miscValidators.isArray(urls) && | 12 | return miscValidators.isArray(hosts) && |
13 | urls.length !== 0 && | 13 | hosts.length !== 0 && |
14 | urls.every(function (url) { | 14 | hosts.every(function (host) { |
15 | return validator.isURL(url) && urls.indexOf(url) === urls.lastIndexOf(url) | 15 | return validator.isURL(host) && host.split('://').length === 1 && hosts.indexOf(host) === hosts.lastIndexOf(host) |
16 | }) | 16 | }) |
17 | } | 17 | } |
18 | 18 | ||
diff --git a/server/helpers/custom-validators/videos.js b/server/helpers/custom-validators/videos.js index 45acb7686..4a6a62326 100644 --- a/server/helpers/custom-validators/videos.js +++ b/server/helpers/custom-validators/videos.js | |||
@@ -15,7 +15,7 @@ const videosValidators = { | |||
15 | isVideoDurationValid, | 15 | isVideoDurationValid, |
16 | isVideoMagnetValid, | 16 | isVideoMagnetValid, |
17 | isVideoNameValid, | 17 | isVideoNameValid, |
18 | isVideoPodUrlValid, | 18 | isVideoPodHostValid, |
19 | isVideoTagsValid, | 19 | isVideoTagsValid, |
20 | isVideoThumbnailValid, | 20 | isVideoThumbnailValid, |
21 | isVideoThumbnail64Valid | 21 | isVideoThumbnail64Valid |
@@ -33,7 +33,7 @@ function isEachRemoteVideosValid (requests) { | |||
33 | isVideoDurationValid(video.duration) && | 33 | isVideoDurationValid(video.duration) && |
34 | isVideoMagnetValid(video.magnet) && | 34 | isVideoMagnetValid(video.magnet) && |
35 | isVideoNameValid(video.name) && | 35 | isVideoNameValid(video.name) && |
36 | isVideoPodUrlValid(video.podUrl) && | 36 | isVideoPodHostValid(video.podHost) && |
37 | isVideoTagsValid(video.tags) && | 37 | isVideoTagsValid(video.tags) && |
38 | isVideoThumbnail64Valid(video.thumbnailBase64) && | 38 | isVideoThumbnail64Valid(video.thumbnailBase64) && |
39 | isVideoRemoteIdValid(video.remoteId) | 39 | isVideoRemoteIdValid(video.remoteId) |
@@ -70,7 +70,7 @@ function isVideoNameValid (value) { | |||
70 | return validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME) | 70 | return validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NAME) |
71 | } | 71 | } |
72 | 72 | ||
73 | function isVideoPodUrlValid (value) { | 73 | function isVideoPodHostValid (value) { |
74 | // TODO: set options (TLD...) | 74 | // TODO: set options (TLD...) |
75 | return validator.isURL(value) | 75 | return validator.isURL(value) |
76 | } | 76 | } |
diff --git a/server/helpers/requests.js b/server/helpers/requests.js index 95775c981..06109ce16 100644 --- a/server/helpers/requests.js +++ b/server/helpers/requests.js | |||
@@ -25,7 +25,7 @@ function makeRetryRequest (params, callback) { | |||
25 | 25 | ||
26 | function makeSecureRequest (params, callback) { | 26 | function makeSecureRequest (params, callback) { |
27 | const requestParams = { | 27 | const requestParams = { |
28 | url: params.toPod.url + params.path | 28 | url: constants.REMOTE_SCHEME.HTTP + '://' + params.toPod.host + params.path |
29 | } | 29 | } |
30 | 30 | ||
31 | // Add data with POST requst ? | 31 | // Add data with POST requst ? |
@@ -34,9 +34,11 @@ function makeSecureRequest (params, callback) { | |||
34 | 34 | ||
35 | // Add signature if it is specified in the params | 35 | // Add signature if it is specified in the params |
36 | if (params.sign === true) { | 36 | if (params.sign === true) { |
37 | const host = constants.CONFIG.WEBSERVER.HOST | ||
38 | |||
37 | requestParams.json.signature = { | 39 | requestParams.json.signature = { |
38 | url: constants.CONFIG.WEBSERVER.URL, | 40 | host, |
39 | signature: peertubeCrypto.sign(constants.CONFIG.WEBSERVER.URL) | 41 | signature: peertubeCrypto.sign(host) |
40 | } | 42 | } |
41 | } | 43 | } |
42 | 44 | ||