1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-27 23:28:38 +02:00

Tools: Updated script to build plugin repository

This commit is contained in:
Laurent Cozic
2021-01-06 20:23:23 +00:00
parent 420ac8359c
commit 8d4d438136
5 changed files with 63 additions and 3 deletions

View File

@ -0,0 +1,11 @@
export default function(id: string): void {
if (!id) throw new Error('ID cannot be empty');
if (id.length > 256) throw new Error('ID cannot be longer than 256 characters');
const whitelist = '0-9a-zA-Z._-';
const regex = new RegExp(`^[${whitelist}]+$`);
if (!id.match(regex)) throw new Error(`ID "${id}" contains invalid characters. Only the characters "${whitelist}" are allowed.`);
if (!id[0].match(/[0-9a-zA-Z]/)) throw new Error('ID can only start with a number or letter');
if (!id[id.length - 1].match(/[0-9a-zA-Z]/)) throw new Error('ID can only end with a number or letter');
}