From f023a19c3eeeea2b014b47fae522a62eab320048 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 5 Jul 2019 15:28:49 +0200 Subject: WIP plugins: install/uninstall --- server/helpers/custom-validators/plugins.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'server/helpers/custom-validators/plugins.ts') diff --git a/server/helpers/custom-validators/plugins.ts b/server/helpers/custom-validators/plugins.ts index ff687dc3f..2fcdc581f 100644 --- a/server/helpers/custom-validators/plugins.ts +++ b/server/helpers/custom-validators/plugins.ts @@ -17,6 +17,13 @@ function isPluginNameValid (value: string) { validator.matches(value, /^[a-z\-]+$/) } +function isNpmPluginNameValid (value: string) { + return exists(value) && + validator.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) && + validator.matches(value, /^[a-z\-]+$/) && + (value.startsWith('peertube-plugin-') || value.startsWith('peertube-theme-')) +} + function isPluginDescriptionValid (value: string) { return exists(value) && validator.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.DESCRIPTION) } @@ -55,7 +62,7 @@ function isCSSPathsValid (css: any[]) { } function isPackageJSONValid (packageJSON: PluginPackageJson, pluginType: PluginType) { - return isPluginNameValid(packageJSON.name) && + return isNpmPluginNameValid(packageJSON.name) && isPluginDescriptionValid(packageJSON.description) && isPluginEngineValid(packageJSON.engine) && isUrlValid(packageJSON.homepage) && @@ -78,5 +85,6 @@ export { isPluginVersionValid, isPluginNameValid, isPluginDescriptionValid, - isLibraryCodeValid + isLibraryCodeValid, + isNpmPluginNameValid } -- cgit v1.2.3