Extracted and de-duplicated the main heuristic logic, making detect() only call main() during heuristic scans. The update reorganizes file-suffix handling and enhances JS content analysis: it skips string literals, properly handles template literals and nested ${...} expressions (using skipNestedTemplate), and distinguishes bytecode vs. plain-text scripts. Detection for minified/compiled code was improved by scanning code segments outside strings with updated regex checks.
Change the Binary.getSize() check from >3000 to >0x400 (1024) so the MiniJavaScript heuristic will run on smaller binary/text inputs. This makes the detector cover scripts between ~1KB and the previous 3KB cutoff, improving detection for smaller embedded scripts.
Escape closing brace and parenthesis inside the regex character class used by the minification heuristic. This corrects the token-matching pattern so punctuation like ";", "}" and ")" are recognized reliably and prevents potential regex parsing issues in db/Binary/__MiniJavaScriptHeuristic_By_DosX.7.sg.
Introduce skipNestedTemplate(s, i) to robustly skip JavaScript template literals, handling nested ${} expressions, inner string literals, escape sequences, and recursion. Replace the previous ad-hoc template-scanning loop in main with a call to this helper when encountering a nested backtick, simplifying the logic and improving correctness when parsing nested templates in scriptContent during heuristic scans.
Improve the MiniJavaScript heuristic parsing: skip escaped characters, properly skip string literals inside expressions, and handle nested template literals (tracking ${} depth) to avoid false positives when scanning script content. Also tighten regexes by switching to non-capturing groups and refining the whitespace/token check used to detect minified/compiled code.
Recognize .jsx, .mjs, and .cjs as JavaScript file types in the MiniJavaScript heuristic. Adds switch cases for JavaScript XML, Module, and CommonJS Module in db/Binary/__MiniJavaScriptHeuristic_By_DosX.7.sg to improve detection of modern JS file extensions.
Modified the regular expression to improve detection of minified or compiled JavaScript code by allowing for more flexible matching of equality and negation operators.
Refactored the script to more accurately split code outside of string literals, handling escaped quotes and template literal expressions. The detection now processes code segments outside of strings, improving reliability when identifying minified or compiled JavaScript.
Changed 'detect' from a constant assignment to a function declaration and replaced string initializations with String() for clarity. These changes improve code readability and maintain consistency in variable initialization.