aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-26 14:44:50 +0200
committerChocobozzz <me@florianbigard.com>2019-07-26 15:18:30 +0200
commitd75db01f14138ea660c4c519e37ab05228b39d13 (patch)
tree85a3da315ea6e1501fec5b70790482504dd64793 /server/helpers/custom-validators
parentee286591a5b740702bad66c55cc900740f749e9a (diff)
downloadPeerTube-d75db01f14138ea660c4c519e37ab05228b39d13.tar.gz
PeerTube-d75db01f14138ea660c4c519e37ab05228b39d13.tar.zst
PeerTube-d75db01f14138ea660c4c519e37ab05228b39d13.zip
Add plugin translation system
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/plugins.ts23
1 files changed, 17 insertions, 6 deletions
diff --git a/server/helpers/custom-validators/plugins.ts b/server/helpers/custom-validators/plugins.ts
index e0a6f98a7..b5e32abc2 100644
--- a/server/helpers/custom-validators/plugins.ts
+++ b/server/helpers/custom-validators/plugins.ts
@@ -44,7 +44,7 @@ function isPluginHomepage (value: string) {
44 return isUrlValid(value) 44 return isUrlValid(value)
45} 45}
46 46
47function isStaticDirectoriesValid (staticDirs: any) { 47function areStaticDirectoriesValid (staticDirs: any) {
48 if (!exists(staticDirs) || typeof staticDirs !== 'object') return false 48 if (!exists(staticDirs) || typeof staticDirs !== 'object') return false
49 49
50 for (const key of Object.keys(staticDirs)) { 50 for (const key of Object.keys(staticDirs)) {
@@ -54,14 +54,24 @@ function isStaticDirectoriesValid (staticDirs: any) {
54 return true 54 return true
55} 55}
56 56
57function isClientScriptsValid (clientScripts: any[]) { 57function areClientScriptsValid (clientScripts: any[]) {
58 return isArray(clientScripts) && 58 return isArray(clientScripts) &&
59 clientScripts.every(c => { 59 clientScripts.every(c => {
60 return isSafePath(c.script) && isArray(c.scopes) 60 return isSafePath(c.script) && isArray(c.scopes)
61 }) 61 })
62} 62}
63 63
64function isCSSPathsValid (css: any[]) { 64function areTranslationPathsValid (translations: any) {
65 if (!exists(translations) || typeof translations !== 'object') return false
66
67 for (const key of Object.keys(translations)) {
68 if (!isSafePath(translations[key])) return false
69 }
70
71 return true
72}
73
74function areCSSPathsValid (css: any[]) {
65 return isArray(css) && css.every(c => isSafePath(c)) 75 return isArray(css) && css.every(c => isSafePath(c))
66} 76}
67 77
@@ -77,9 +87,10 @@ function isPackageJSONValid (packageJSON: PluginPackageJson, pluginType: PluginT
77 exists(packageJSON.author) && 87 exists(packageJSON.author) &&
78 isUrlValid(packageJSON.bugs) && 88 isUrlValid(packageJSON.bugs) &&
79 (pluginType === PluginType.THEME || isSafePath(packageJSON.library)) && 89 (pluginType === PluginType.THEME || isSafePath(packageJSON.library)) &&
80 isStaticDirectoriesValid(packageJSON.staticDirs) && 90 areStaticDirectoriesValid(packageJSON.staticDirs) &&
81 isCSSPathsValid(packageJSON.css) && 91 areCSSPathsValid(packageJSON.css) &&
82 isClientScriptsValid(packageJSON.clientScripts) 92 areClientScriptsValid(packageJSON.clientScripts) &&
93 areTranslationPathsValid(packageJSON.translations)
83} 94}
84 95
85function isLibraryCodeValid (library: any) { 96function isLibraryCodeValid (library: any) {