X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fvideo-captions.ts;h=528edf60ce6810a01a19b1491eb42f7438e38b8d;hb=de6310b2fcbb8a6b79c546b23dfa1920724faaa7;hp=d06eb3695216295d3239d49a53d2070b4c7c2059;hpb=3e753302d8c911b59971c16a8018df0e1ab78465;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/video-captions.ts b/server/helpers/custom-validators/video-captions.ts index d06eb3695..528edf60c 100644 --- a/server/helpers/custom-validators/video-captions.ts +++ b/server/helpers/custom-validators/video-captions.ts @@ -2,13 +2,13 @@ import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initialize import { exists, isFileValid } from './misc' function isVideoCaptionLanguageValid (value: any) { - return exists(value) && VIDEO_LANGUAGES[ value ] !== undefined + return exists(value) && VIDEO_LANGUAGES[value] !== undefined } -const videoCaptionTypes = Object.keys(MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT) - .concat([ 'application/octet-stream' ]) // MacOS sends application/octet-stream >< +const videoCaptionTypesRegex = Object.keys(MIMETYPES.VIDEO_CAPTIONS.MIMETYPE_EXT) + .concat([ 'application/octet-stream' ]) // MacOS sends application/octet-stream .map(m => `(${m})`) -const videoCaptionTypesRegex = videoCaptionTypes.join('|') + .join('|') function isVideoCaptionFile (files: { [ fieldname: string ]: Express.Multer.File[] } | Express.Multer.File[], field: string) { return isFileValid(files, videoCaptionTypesRegex, field, CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max) }