Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
test(relay): bare-fetch guard also catches ?? / || / && fetch defaults
Bugfixer 291a80f825eb7
diff --git a/src/lib/relay-server-callers.test.ts b/src/lib/relay-server-callers.test.tsindex d9b0139923..97f6befec5 100644--- a/src/lib/relay-server-callers.test.ts+++ b/src/lib/relay-server-callers.test.ts@@ -16,8 +16,8 @@ function appFiles(): string[] {}/** A call to fetch, whitespace or a line break before its `(` too, or fetch handed on as a value (`fetchImpl = fetch`,- * `run(fetch)`); not `.fetch(` or a `fetch:` key. */-const BARE_FETCH = /(?<![\w$.])fetch\s*\(|[=(,:]\s*fetch\b(?![\w$.(]|\s*[:(])/g;+ * `run(fetch)`, `impl ?? fetch`, `custom || fetch`); not `.fetch(` or a `fetch:` key. */+const BARE_FETCH = /(?<![\w$.])fetch\s*\(|(?:[=(,:]|\?\?|\|\||&&)\s*fetch\b(?![\w$.(]|\s*[:(])/g;/** The 1-based lines of `source` with a bare fetch, `//` comments left out. */function bareFetchLines(source: string): number[] {@@ -37,6 +37,8 @@ describe("app requests to its own server", () => {expect(bareFetchLines('void fetch ("/api/bots");')).toEqual([1]);expect(bareFetchLines('const a = 1;\nawait fetch\n ("/api/bots");')).toEqual([2]);expect(bareFetchLines("const run = fetch;\nuse(fetch)")).toEqual([1, 2]);+ expect(bareFetchLines('const impl = options.fetchImpl ?? fetch;\nconst alt = custom || fetch;')).toEqual([1, 2]);expect(bareFetchLines('link.fetch("/api/bots");\nconst x = { fetch: go };\n// fetch("/api/bots")\nserverFetch("/api/bots");')).toEqual([]);+ expect(bareFetchLines("const UNREACHABLE = /Load failed|fetch failed$/i;")).toEqual([]);});});