Skip to content

Serve .ipuz downloads as application/octet-stream - #604

Open
fokality wants to merge 1 commit into
crosshare-org:masterfrom
fokality:fix-ipuz-android-extension
Open

fokality wants to merge 1 commit into
crosshare-org:masterfrom
fokality:fix-ipuz-android-extension

Conversation

@fokality

Copy link
Copy Markdown

Fixes #603

Problem

Downloading a puzzle as .ipuz on Android produces puzzle.ipuz.json. /api/ipuz/[puzzleId] responds with Content-Type: application/json, and Android appends .json to the filename for that type.

Change

Send the response as application/octet-stream so the .ipuz extension is preserved. Content-Disposition and the other headers are unchanged.

Testing

  • Verified the bug on an Android phone against a local dev instance (got .ipuz.json), and verified the fix on the same device (now .ipuz).
  • Added app/__tests__/ipuzApi.test.ts, which calls the route handler with getPuzzle/exportIpuz mocked and asserts the Content-Type and Content-Disposition headers. It fails without the fix.
  • Existing converter tests still pass; eslint, tsc --noEmit and prettier are clean on the changed files.

This adds the first API route test, using jest.unstable_mockModule. Happy to add similar header tests for the puz and pdf routes in a follow-up if that's useful.

🤖 Generated with Claude Code

Android appends ".json" to files served as application/json, so
downloading an .ipuz produced "puzzle.ipuz.json". Send the file as
application/octet-stream so the .ipuz extension is preserved.

Adds a regression test for the response headers of /api/ipuz/[puzzleId].

Fixes crosshare-org#603

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@fokality

fokality commented Oct 15, 2026 •

Copy link
Copy Markdown
Author

Note on alternatives: I also tried switching Content-Disposition from inline to attachment while keeping Content-Type: application/json. On Android the download was still named .ipuz.json, so the content type is what causes the extension to be appended. That's why this PR changes Content-Type rather than the disposition.

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.

ipuz download on android gives you a file with an .ipuz.json extension

1 participant