MCPcopy Create free account
hub / github.com/MiniMax-AI/OpenRoom / extractResources

Function extractResources

apps/webuiapps/src/lib/cardExtractor.ts:410–438  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

408// ── Resource extraction ────────────────────────────────────────────
409
410function extractResources(content: string): Record<string, string[]> {
411 const resources: Record<string, string[]> = {};
412
413 const pattern = new RegExp(
414 `<(${RESOURCE_LIST_NAMES.join('|')})>\\s*\\n([\\s\\S]*?)\\n\\s*</\\1>`,
415 'g',
416 );
417 let m;
418 while ((m = pattern.exec(content)) !== null) {
419 const listName = m[1];
420 const body = m[2];
421 const files = body
422 .split('\n')
423 .map((l) => l.trim().replace(/^(\u200b|\u200c|\u200d|\uFEFF)+/, ''))
424 .filter((l) => l && /\.\w{2,4}$/.test(l));
425 resources[listName] = files;
426 }
427
428 const jsonM = /```json\s*\n\{\s*\n\[\s*\n([\s\S]*?)\]\s*\n\}\s*\n```/.exec(content);
429 if (jsonM) {
430 const stickers = jsonM[1]
431 .split('\n')
432 .map((l) => l.trim())
433 .filter((l) => l && /\.\w{2,5}$/.test(l));
434 resources['stickers'] = stickers;
435 }
436
437 return resources;
438}
439
440// ── Format & example ──────────────────────────────────────────────
441

Callers 1

extractAppsFromEntriesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected