X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fplugins.ts;h=60b29dc894b87aa0fba870f2d6d746915204054d;hb=67ad83d0faa5924a566bc8260918439614694c85;hp=5a4531f72ebdea684bdddcb105276d2c0497639f;hpb=2ad9dcda240ee843c5e4a5b98cc94f7b2aab2c89;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/plugins.ts b/server/helpers/custom-validators/plugins.ts index 5a4531f72..60b29dc89 100644 --- a/server/helpers/custom-validators/plugins.ts +++ b/server/helpers/custom-validators/plugins.ts @@ -2,19 +2,20 @@ import { exists, isArray, isSafePath } from './misc' import validator from 'validator' import { PluginType } from '../../../shared/models/plugins/plugin.type' import { CONSTRAINTS_FIELDS } from '../../initializers/constants' -import { PluginPackageJson } from '../../../shared/models/plugins/plugin-package-json.model' +import { PluginPackageJSON } from '../../../shared/models/plugins/plugin-package-json.model' import { isUrlValid } from './activitypub/misc' const PLUGINS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.PLUGINS function isPluginTypeValid (value: any) { - return exists(value) && validator.isInt('' + value) && PluginType[value] !== undefined + return exists(value) && + (value === PluginType.PLUGIN || value === PluginType.THEME) } function isPluginNameValid (value: string) { return exists(value) && validator.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) && - validator.matches(value, /^[a-z-]+$/) + validator.matches(value, /^[a-z-0-9]+$/) } function isNpmPluginNameValid (value: string) { @@ -83,7 +84,7 @@ function isThemeNameValid (name: string) { return isPluginNameValid(name) } -function isPackageJSONValid (packageJSON: PluginPackageJson, pluginType: PluginType) { +function isPackageJSONValid (packageJSON: PluginPackageJSON, pluginType: PluginType) { let result = true const badFields: string[] = []