You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-24 23:26:50 +02:00
Tools: Various improvements on plugin-repo-cli
This commit is contained in:
@ -4,11 +4,12 @@ describe('validatePluginId', () => {
|
||||
|
||||
test('should validate an ID', () => {
|
||||
const okCases = [
|
||||
'thatsok',
|
||||
'that-s-ok',
|
||||
'that_s_fine12',
|
||||
'com.ok.too',
|
||||
'Good',
|
||||
'joplinapp.org.plugins.thatsok',
|
||||
'joplinapp.org.plugins.that-s-ok',
|
||||
'joplinapp.org.plugins.that_s_fine12',
|
||||
'joplinapp.org.plugins.com.ok.too',
|
||||
'joplinapp.org.plugins.Good',
|
||||
'outline',
|
||||
];
|
||||
|
||||
const errorCases = [
|
||||
@ -16,8 +17,9 @@ describe('validatePluginId', () => {
|
||||
'verylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongid',
|
||||
'-shouldstartwiththis',
|
||||
'shouldntendwithit.',
|
||||
' no space ',
|
||||
'no space',
|
||||
' no space no space no space no space ',
|
||||
'no spaceno spaceno spaceno spaceno space',
|
||||
'tooshort',
|
||||
];
|
||||
|
||||
for (const t of okCases) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
export default function(id: string): void {
|
||||
if (!id) throw new Error('ID cannot be empty');
|
||||
// Allow a few exceptions that existed before the limit was added
|
||||
if (id.length < 16 && !['Outline', 'outline', 'MyPlugin'].includes(id)) throw new Error('ID cannot be shorter than 16 characters');
|
||||
if (id.length > 256) throw new Error('ID cannot be longer than 256 characters');
|
||||
|
||||
const whitelist = '0-9a-zA-Z._-';
|
||||
|
Reference in New Issue
Block a user