core: problem: fix get without namespaces

This commit is contained in:
undefined committed 2024-10-21 22:41:54 +08:00
1 parent ba8f81d6e9
commit 68eb1b8789
1 file changed
+1 -1
+1 -1
View File
@@ -33,7 +33,7 @@ export interface ProblemDoc extends Document { }
export type Field = keyof ProblemDoc; export type Field = keyof ProblemDoc;
const logger = new Logger('problem'); const logger = new Logger('problem');
function sortable(source: string, namespaces: Record<string, string> = {}) { function sortable(source: string, namespaces: Record<string, string>) {
const [namespace, pid] = source.includes('-') ? source.split('-') : ['default', source]; const [namespace, pid] = source.includes('-') ? source.split('-') : ['default', source];
return ((namespaces ? `${namespaces[namespace]}-` : '') + pid) return ((namespaces ? `${namespaces[namespace]}-` : '') + pid)
.replace(/(\d+)/g, (str) => (str.length >= 6 ? str : ('0'.repeat(6 - str.length) + str))); .replace(/(\d+)/g, (str) => (str.length >= 6 ? str : ('0'.repeat(6 - str.length) + str)));