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

Function classifyScript

apps/webuiapps/src/lib/cardExtractor.ts:590–613  ·  view source on GitHub ↗
(script: InternalScript, regexTags: string[])

Source from the content-addressed store, hash-verified

588}
589
590function classifyScript(script: InternalScript, regexTags: string[]): string {
591 const replaceStr = script.replaceString || '';
592 const findRegex = script.findRegex || '';
593
594 if (replaceStr.length > 500 && (replaceStr.includes('<div') || replaceStr.includes('<style'))) {
595 return 'layout';
596 }
597 if (/< \w+>.*\[\^.*\]/.test(findRegex) && replaceStr.includes('<img src=')) {
598 return 'image-open';
599 }
600 if (/<\/\w+>/.test(findRegex) && replaceStr.includes('style=')) {
601 return 'image-close';
602 }
603 if (
604 regexTags.some((t) => ['ch1', 'ch2', 'um1', 'um2', 'pl1', 'pl2'].includes(t)) &&
605 replaceStr.includes('border-radius')
606 ) {
607 return 'chat-bubble';
608 }
609 if (replaceStr.includes('<span') || replaceStr.includes('<br>')) {
610 return 'formatting';
611 }
612 return 'transform';
613}
614
615function normalizeScripts(
616 rawScripts: InternalScript[],

Callers 1

normalizeScriptsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected