Skip to content

Make the factorioprints comment agree with itself, and strip www. once - #294

Merged
wormeyman merged 1 commit into
FactoryGameFan:wormeyman-space-age-supportfrom
byalex33:fix-293-factorioprints-comment
Sep 1, 2026
Merged

Make the factorioprints comment agree with itself, and strip www. once#294
wormeyman merged 1 commit into
FactoryGameFan:wormeyman-space-age-supportfrom
byalex33:fix-293-factorioprints-comment

Conversation

@byalex33

@byalex33 byalex33 commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Closes #293.

The contradiction

The factorioprints arm's comment in bpString.ts had two paragraphs that disagreed:

  • Paragraph one: rewriting an /api/blueprintData/<sha>/position/<i> link to firebase "would drop the position and open the book instead of the blueprint that was linked."
  • Paragraph two: the same rewrite "200s with a body of null and data.blueprintString throws."

The second is right. The rewrite uses pathParts[1], which for an API path is the literal string blueprintData, not a blueprint key, so it fetches blueprints/blueprintData.json — a record that does not exist — and throws on the parse. It never reaches the book.

The pre-#291 comment had the accurate pathParts[1] explanation; #291's review asked for a wrong trailing clause to be fixed, and the rewrite dropped the accurate half with it. This restores it and drops the book consequence, so paragraph one now describes the same failure as paragraph two (same shape as #284).

While in there: strip www. once

bpString.ts stripped a leading www. twice — once to pick the switch label, once to compare the host in the factorioprints arm — with nothing keeping the two copies in agreement (per #293, they were held up by different spec mutations). Hoisted into one const host above the switch, read in both places. Pure refactor, no behaviour change.

Note added, not a task

Added a sentence on case 'factorio' explaining it keys on the path alone because no other factorio.<tld> is known to reach it — not because that is inherently safe. #291's comment contrasted the two arms without saying why the school arm is fine without a host check.

Verification

Comment change plus a hoist of an identical expression into a const. The Vite+ toolchain isn't installed in my environment so I couldn't run vp check / the Playwright blueprint-sources.spec.ts locally; CI covers both. The two www.-strip mutations from #293 (a www.factorioprints.xyz API url is passed through unchanged and factorio.school reads the doubly nested blueprintString) both now exercise the single host binding.

🤖 Generated with Claude Code

The comment's first paragraph said rewriting an /api/blueprintData/<sha>/
position/<i> link to firebase "would drop the position and open the book";
its second paragraph said the same rewrite 200s with a null body and throws.
Only the second is true - `pathParts[1]` of an API path is the literal
`blueprintData`, so the rewrite fetches blueprints/blueprintData.json, a
record that does not exist. Put the `pathParts[1]` explanation back (the
pre-FactoryGameFan#291 comment had it) and drop the book consequence, so both paragraphs
describe the same failure.

Also hoist the `www.` strip into one `const host` read by both the switch
discriminant and the factorioprints host check, instead of two copies that
nothing keeps in agreement. Pure refactor, no behaviour change.

While in there, note on `case 'factorio'` that it keys on the path alone
because no other factorio.<tld> is known to reach it, not because that is
inherently safe - FactoryGameFan#291 contrasted the two arms without saying so.

Closes FactoryGameFan#293

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@wormeyman
wormeyman merged commit 65eec0b into FactoryGameFan:wormeyman-space-age-support Sep 1, 2026
9 checks passed
wormeyman added a commit that referenced this pull request Sep 1, 2026
Comments only, in tests/blueprint-sources.spec.ts. No code or test change.

The first said the firebase record a factorioprints API link rewrites to
"holds only the whole book - so a rewrite here would load the book and lose
the position". That is the claim #293 refuted: `pathParts[1]` of an API path
is the literal string `blueprintData`, not a blueprint key, so the rewrite
asks for `blueprints/blueprintData.json`, which answers 200 with a body of
`null`, and `data.blueprintString` throws. It never reaches the book. The
next test in the file already pins that exact target, so the comment now
points at it.

The second said that without the `www.` strip a link to
`www.factorioprints.xyz` "would take the firebase rewrite". That was true
while the host check had its own copy of the strip. #294 hoisted the two
copies into one `const host`, so deleting the single strip now keys the
switch on `www`, which falls to `default` - the same
`fetchData(url.href).then(r => r.text())` as the pass-through, so this test
stays green. Measured on the merged head: deleting it fails exactly one
test, `factorio.school reads the doubly nested blueprintString`. The comment
says so, and points the strip's own coverage at that test.

Verified with `vp check` and
`npx playwright test tests/blueprint-sources.spec.ts` (15 passed).

Follow-up to #294 and #293.


Claude-Session: https://claude.ai/code/session_014hQpEsZojx1pWE9kHn75MH

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The factorioprints arm's comment contradicts itself about what a rewritten API link does

2 participants