{"draft":null,"from":150,"to":151,"files":[{"path":"client/test/issues.test.ts","added":36,"removed":10,"diff":"--- a/client/test/issues.test.ts\n+++ b/client/test/issues.test.ts\n@@ -13,7 +13,7 @@\n import { join } from \"node:path\";\n import { after, before, describe, it } from \"node:test\";\n import { readConfig, readMachineServers } from \"../src/config.ts\";\n-import { issuesServerFor, tokenGoesTo } from \"../src/core.ts\";\n+import { issuesServerFor, tokenGoesTo, tokenGoesToIssues } from \"../src/core.ts\";\n import { issuePage, searchLines } from \"../src/issues.ts\";\n import type { IssuePage } from \"../src/issues-wire.ts\";\n import { main } from \"../src/main.ts\";\n@@ -176,16 +176,42 @@\n \t\tassert.equal(r.exit, 1, r.out);\n \t\tassert.match(r.out, /sends your token only to its own servers and this machine/);\n \t\tassert.equal(seen.length, before);\n-\t\t// A server with no Issues Worker beside it, and none named.\n-\t\tconst { AVCS_ISSUES_SERVER: _, ...without } = ENV();\n-\t\tconst none = await avcs(dave, [\"waiting\"], without);\n-\t\tassert.notEqual(none.exit, 0);\n-\t\tassert.match(\n-\t\t\tnone.out,\n-\t\t\t/has no Issues Worker beside it that abso knows; ~\\/\\.abso\\/servers\\.json or ABSO_ISSUES_SERVER names one/,\n-\t\t);\n \t});\n \n+\tit(\"with no Issues Worker named, uses the server's own /issues, as the open server keeps them\", () => {\n+\t\tassert.equal(issuesServerFor(\"https://abso.example\"), \"https://abso.example/issues\");\n+\t\tassert.equal(issuesServerFor(\"https://Abso.Example/\"), \"https://abso.example/issues\");\n+\t\tassert.equal(issuesServerFor(\"http://localhost:8787\"), \"http://localhost:8787/issues\");\n+\t\tassert.equal(issuesServerFor(\"not a server\"), undefined);\n+\t\t// abso's hosted server keeps its own Issues Worker, and servers.json still comes first.\n+\t\tassert.equal(issuesServerFor(\"https://api.abso.dev\"), \"https://issues.abso.dev\");\n+\t\tconst machine = {\n+\t\t\ttrusted: [],\n+\t\t\tissues: { \"https://staging.abso.example\": \"https://issues-staging.abso.example\" },\n+\t\t};\n+\t\tassert.equal(issuesServerFor(\"https://staging.abso.example\", machine), \"https://issues-staging.abso.example\");\n+\t\t// The token goes to <server>/issues exactly where it goes to <server>.\n+\t\tassert.ok(tokenGoesToIssues(\"https://api.abso.dev/issues\"));\n+\t\tassert.ok(tokenGoesToIssues(\"http://localhost:8787/issues\"));\n+\t\tassert.ok(tokenGoesToIssues(\"https://mine.example/issues\", \"https://mine.example\"));\n+\t\tassert.equal(tokenGoesToIssues(\"https://evil.example/issues\"), false);\n+\t\tassert.equal(tokenGoesToIssues(\"https://api.abso.dev@evil.example/issues\"), false);\n+\t\tassert.equal(tokenGoesToIssues(\"https://api.abso.dev/issues?x=1\"), false);\n+\t\tassert.equal(tokenGoesToIssues(\"http://mine.example/issues\", \"http://mine.example\"), false, \"plain http only here\");\n+\t\t// The server itself still takes no path.\n+\t\tassert.equal(tokenGoesTo(\"https://api.abso.dev/issues\"), false);\n+\t});\n+\n+\tit(\"calls <issues server>/p/<project>/... when the Issues Worker is at a path\", async () => {\n+\t\tconst fay = await folder(\"fay\");\n+\t\tconst before = seen.length;\n+\t\tconst env = { ...ENV(), AVCS_ISSUES_SERVER: `${issuesUrl}/issues` };\n+\t\tconst r = await main([\"ask\", \"7\"], { cwd: fay, env, write: () => {} });\n+\t\tassert.equal(r.exit, 0, r.stdout + r.stderr);\n+\t\tconst { project } = readConfig(fay);\n+\t\tassert.deepEqual(seen.slice(before), [`GET /issues/p/${project}/ask/7`]);\n+\t});\n+\n \tit(\"finds a server's Issues Worker in this machine's servers.json, and may send it the token\", async () => {\n \t\tconst dir = mkdtempSync(join(tmpdir(), \"abso-servers-\"));\n \t\tdirs.push(dir);\n@@ -198,7 +224,7 @@\n \t\tassert.ok(seen.length > before, \"the call went to the Issues Worker servers.json names\");\n \t\tconst machine = readMachineServers({ AVCS_SERVERS_FILE: file });\n \t\tassert.equal(issuesServerFor(fake.url, machine), issuesUrl);\n-\t\tassert.equal(issuesServerFor(\"https://abso.example\", machine), undefined);\n+\t\tassert.equal(issuesServerFor(\"https://abso.example\", machine), \"https://abso.example/issues\");\n \t\t// abso's own server and its Issues Worker are built in.\n \t\tassert.ok(tokenGoesTo(\"https://api.abso.dev\"));\n \t\tassert.ok(tokenGoesTo(\"https://issues.abso.dev\"));"}],"unmatched":[]}