Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(guards): stop the source scanners reading prose and value expressions as code

nirholas5fb67cf31727
diff --git a/scripts/audit-links.mjs b/scripts/audit-links.mjs
index 7a18a6fdb..99855fb9b 100644
--- a/scripts/audit-links.mjs
+++ b/scripts/audit-links.mjs
@@ -191,9 +191,22 @@ function classifyTarget(value) {
// Lookbehind blocks `data-action`/`reaction`/etc. from matching the bare `action`
// attribute — only a real navigable attribute (preceded by whitespace or tag-open).
const htmlAttrRe = /(?<![\w-])(?:href|formaction|action|data-href|data-route|data-link|data-target-href)\s*=\s*("([^"]*)"|'([^']*)')/gi;
-const jsNavRe = /(?:\.href\s*=|location\.(?:assign|replace)\s*\(|window\.open\s*\(|\bhref\s*:|\bnavigateTo\s*\(|\brouteTo\s*\()\s*("([^"]*)"|'([^']*)'|`([^`$]*)`)/gi;
+// The `href:` alternative targets an object-literal property (`{ href: '/x' }`).
+// The lookbehind keeps it off a *property read* followed by a ternary colon —
+// `new URL(x, origin).href : ''` is a value expression, not a navigation.
+const jsNavRe = /(\.href\s*=|location\.(?:assign|replace)\s*\(|window\.open\s*\(|(?<![.\w$])href\s*:|\bnavigateTo\s*\(|\brouteTo\s*\()\s*("([^"]*)"|'([^']*)'|`([^`$]*)`)/gi;
const fetchRe = /\bfetch\s*\(\s*("([^"]*)"|'([^']*)'|`([^`$]*)`)/gi;
+// A string literal immediately followed by `+` is only the *head* of a computed
+// URL (`dot.href = '#' + section.id`, `fetch('/login?next=' + to)`). Its path
+// prefix is still worth resolving — that catches a renamed route — but it can
+// never be a stub: the part that makes the target real is the concatenated tail.
+function concatenatedAfter(content, endIndex) {
+ let i = endIndex;
+ while (i < content.length && (content[i] === ' ' || content[i] === '\t')) i++;
+ return content[i] === '+';
+}
+
function lineOf(content, index) {
let line = 1;
for (let i = 0; i < index && i < content.length; i++) if (content[i] === '\n') line++;
@@ -208,12 +221,13 @@ const findings = {
scanned: 0,
};
-function record(target, file, line) {
+function record(target, file, line, isPrefix = false) {
const rel = file.replace(ROOT + '/', '');
const baseDir = dirname(rel); // for resolving relative links from this file's dir
const c = classifyTarget(target);
if (c.type === 'stub') {
- findings.stubs.push({ file: rel, line, value: c.value });
+ if (isPrefix) findings.dynamic++; // head of a computed URL, not a dead target
+ else findings.stubs.push({ file: rel, line, value: c.value });
return;
}
if (c.type === 'external') {
@@ -250,7 +264,11 @@ function scanFile(file) {
}
jsNavRe.lastIndex = 0;
while ((m = jsNavRe.exec(content))) {
- record(m[2] ?? m[3] ?? m[4] ?? '', file, lineOf(content, m.index));
+ const target = m[3] ?? m[4] ?? m[5] ?? '';
+ // `window.open('')` opens a blank tab the caller then writes into — a real
+ // pattern, not a link to nowhere.
+ if (target === '' && /^window\.open/i.test(m[1])) continue;
+ record(target, file, lineOf(content, m.index), concatenatedAfter(content, m.index + m[0].length));
}
fetchRe.lastIndex = 0;
while ((m = fetchRe.exec(content))) {