]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/plugins.ts
Merge branch 'release/2.1.0' into develop
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / plugins.ts
index 2e317574232dae9357c5e8d9febde464a1f10b74..5a4531f72ebdea684bdddcb105276d2c0497639f 100644 (file)
@@ -1,5 +1,5 @@
 import { exists, isArray, isSafePath } from './misc'
-import * as validator from 'validator'
+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'
@@ -14,13 +14,13 @@ function isPluginTypeValid (value: any) {
 function isPluginNameValid (value: string) {
   return exists(value) &&
     validator.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) &&
-    validator.matches(value, /^[a-z\-]+$/)
+    validator.matches(value, /^[a-z-]+$/)
 }
 
 function isNpmPluginNameValid (value: string) {
   return exists(value) &&
     validator.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) &&
-    validator.matches(value, /^[a-z\-]+$/) &&
+    validator.matches(value, /^[a-z\-._0-9]+$/) &&
     (value.startsWith('peertube-plugin-') || value.startsWith('peertube-theme-'))
 }
 
@@ -146,8 +146,8 @@ function isPackageJSONValid (packageJSON: PluginPackageJson, pluginType: PluginT
 }
 
 function isLibraryCodeValid (library: any) {
-  return typeof library.register === 'function'
-    && typeof library.unregister === 'function'
+  return typeof library.register === 'function' &&
+    typeof library.unregister === 'function'
 }
 
 export {