From 556ddc319242aafef51bae9301423ecf8701a3af Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 25 Aug 2017 18:36:49 +0200 Subject: Upgrade common server dependencies --- server/helpers/custom-validators/misc.ts | 10 ++-- server/helpers/custom-validators/pods.ts | 23 ++++++--- server/helpers/custom-validators/remote/videos.ts | 12 ++--- server/helpers/custom-validators/users.ts | 14 +++--- server/helpers/custom-validators/videos.ts | 58 +++++++++++------------ 5 files changed, 59 insertions(+), 58 deletions(-) (limited to 'server/helpers/custom-validators') diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index b1291ba7a..f6bb02c8e 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts @@ -13,11 +13,9 @@ export { isArray } -declare global { - namespace ExpressValidator { - export interface Validator { - exists, - isArray - } +declare module 'express-validator' { + export interface Validator { + exists, + isArray } } diff --git a/server/helpers/custom-validators/pods.ts b/server/helpers/custom-validators/pods.ts index 0519def52..f2ca520c0 100644 --- a/server/helpers/custom-validators/pods.ts +++ b/server/helpers/custom-validators/pods.ts @@ -1,9 +1,20 @@ import * as validator from 'validator' import { isArray, exists } from './misc' +import { isTestInstance } from '../core-utils' function isHostValid (host: string) { - return exists(host) && validator.isURL(host) && host.split('://').length === 1 + const isURLOptions = { + require_host: true, + require_tld: true + } + + // We validate 'localhost', so we don't have the top level domain + if (isTestInstance()) { + isURLOptions.require_tld = false + } + + return exists(host) && validator.isURL(host, isURLOptions) && host.split('://').length === 1 } function isEachUniqueHostValid (hosts: string[]) { @@ -21,11 +32,9 @@ export { isHostValid } -declare global { - namespace ExpressValidator { - export interface Validator { - isEachUniqueHostValid - isHostValid - } +declare module 'express-validator' { + export interface Validator { + isEachUniqueHostValid + isHostValid } } diff --git a/server/helpers/custom-validators/remote/videos.ts b/server/helpers/custom-validators/remote/videos.ts index 091cd2186..49f76e909 100644 --- a/server/helpers/custom-validators/remote/videos.ts +++ b/server/helpers/custom-validators/remote/videos.ts @@ -101,13 +101,11 @@ export { isEachRemoteRequestVideosEventsValid } -declare global { - namespace ExpressValidator { - export interface Validator { - isEachRemoteRequestVideosValid, - isEachRemoteRequestVideosQaduValid, - isEachRemoteRequestVideosEventsValid - } +declare module 'express-validator' { + export interface Validator { + isEachRemoteRequestVideosValid, + isEachRemoteRequestVideosQaduValid, + isEachRemoteRequestVideosEventsValid } } diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 750563ada..2b37bdde8 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts @@ -34,13 +34,11 @@ export { isUserDisplayNSFWValid } -declare global { - namespace ExpressValidator { - export interface Validator { - isUserPasswordValid, - isUserRoleValid, - isUserUsernameValid, - isUserDisplayNSFWValid - } +declare module 'express-validator' { + export interface Validator { + isUserPasswordValid, + isUserRoleValid, + isUserUsernameValid, + isUserDisplayNSFWValid } } diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 139fa760f..8b3a26644 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts @@ -168,35 +168,33 @@ export { isVideoFileResolutionValid } -declare global { - namespace ExpressValidator { - export interface Validator { - isVideoIdOrUUIDValid, - isVideoAuthorValid, - isVideoDateValid, - isVideoCategoryValid, - isVideoLicenceValid, - isVideoLanguageValid, - isVideoNSFWValid, - isVideoDescriptionValid, - isVideoDurationValid, - isVideoInfoHashValid, - isVideoNameValid, - isVideoTagsValid, - isVideoThumbnailValid, - isVideoThumbnailDataValid, - isVideoExtnameValid, - isVideoUUIDValid, - isVideoAbuseReasonValid, - isVideoAbuseReporterUsernameValid, - isVideoFile, - isVideoViewsValid, - isVideoLikesValid, - isVideoRatingTypeValid, - isVideoDislikesValid, - isVideoEventCountValid, - isVideoFileSizeValid, - isVideoFileResolutionValid - } +declare module 'express-validator' { + export interface Validator { + isVideoIdOrUUIDValid, + isVideoAuthorValid, + isVideoDateValid, + isVideoCategoryValid, + isVideoLicenceValid, + isVideoLanguageValid, + isVideoNSFWValid, + isVideoDescriptionValid, + isVideoDurationValid, + isVideoInfoHashValid, + isVideoNameValid, + isVideoTagsValid, + isVideoThumbnailValid, + isVideoThumbnailDataValid, + isVideoExtnameValid, + isVideoUUIDValid, + isVideoAbuseReasonValid, + isVideoAbuseReporterUsernameValid, + isVideoFile, + isVideoViewsValid, + isVideoLikesValid, + isVideoRatingTypeValid, + isVideoDislikesValid, + isVideoEventCountValid, + isVideoFileSizeValid, + isVideoFileResolutionValid } } -- cgit v1.2.3