1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 09:49:20 +02:00

Revert "fix: plugin/theme names with scope are not allowed"

This reverts commit 8426746bf1.
This commit is contained in:
Chocobozzz 2025-04-02 14:36:11 +02:00
parent 8426746bf1
commit e9f887323a
No known key found for this signature in database
GPG key ID: 583A612D890159BE

View file

@ -6,10 +6,6 @@ import { exists, isArray, isSafePath } from './misc.js'
const PLUGINS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.PLUGINS const PLUGINS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.PLUGINS
const NPM_VALIDATION_RE = new RegExp(
/^(@[^\._][a-z-_\.~0-9]+\/)?([a-z-0-9]+)$/,
);
function isPluginTypeValid (value: any) { function isPluginTypeValid (value: any) {
return exists(value) && return exists(value) &&
(value === PluginType.PLUGIN || value === PluginType.THEME) (value === PluginType.PLUGIN || value === PluginType.THEME)
@ -18,16 +14,14 @@ function isPluginTypeValid (value: any) {
function isPluginNameValid (value: string) { function isPluginNameValid (value: string) {
return exists(value) && return exists(value) &&
validator.default.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) && validator.default.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) &&
validator.default.matches(value, NPM_VALIDATION_RE) validator.default.matches(value, /^[a-z-0-9]+$/)
} }
function isNpmPluginNameValid (value: string) { function isNpmPluginNameValid (value: string) {
const match = value.match(NPM_VALIDATION_RE);
return exists(value) && return exists(value) &&
validator.default.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) && validator.default.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) &&
validator.default.matches(value, NPM_VALIDATION_RE) && validator.default.matches(value, /^[a-z\-._0-9]+$/) &&
(match[2].startsWith("peertube-plugin-") || (value.startsWith('peertube-plugin-') || value.startsWith('peertube-theme-'))
match[2].startsWith("peertube-theme-"))
} }
function isPluginDescriptionValid (value: string) { function isPluginDescriptionValid (value: string) {