MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / isValidPid

Method isValidPid

packages/hydrooj/src/model/problem.ts:521–534  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

519 let overridePid = null;
520
521 const isValidPid = async (id: string) => {
522 if (!(/^(?:[a-z0-9]{1,10}-)?[a-z][0-9a-z]*$/i.test(id))) return false;
523 if (id.includes('-')) {
524 const [prefix] = id.split('-');
525 if (!ddoc?.namespaces?.[prefix]) return false;
526 }
527 const doc = await ProblemModel.get(ddoc._id, id);
528 if (doc) {
529 if (!override) return false;
530 overridePid = doc.docId;
531 return true;
532 }
533 return true;
534 };
535 const getFiles = async (...type: string[]): Promise<[fs.Dirent, string][]> => {
536 if (type.length > 1) {
537 let result = [];

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected