core: optimize regex for isValidPid

This commit is contained in:
undefined committed 2025-01-21 07:35:20 +08:00
1 parent f2c66df1c2
commit 3ea0699c20
3 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -46,7 +46,7 @@ class ImportHojHandler extends Handler {
content.samples = examples.map((sample) => ([sample.input, sample.output]));
}
const isValidPid = async (id: string) => {
if (!(/^[A-Za-z]+[0-9A-Za-z]*$/.test(id))) return false;
if (!(/^[A-Za-z][0-9A-Za-z]*$/.test(id))) return false;
if (await ProblemModel.get(domainId, id)) return false;
return true;
};