Skip to content

Compact short share links (personas.draftbit.com/<code>)#84

Open
bluerssen wants to merge 1 commit into
masterfrom
short-links
Open

Compact short share links (personas.draftbit.com/<code>)#84
bluerssen wants to merge 1 commit into
masterfrom
short-links

Conversation

@bluerssen

Copy link
Copy Markdown
Contributor

Summary

Share links shrink from ~200-char query strings to personas.draftbit.com/<code> — 12 characters for palette-color avatars, up to 31 with custom hex colors. Stateless: the code is the bit-packed avatar config (no KV, nothing to expire or migrate).

  • Codec in shareUrl.js: 4-bit version + per-category style indices + per-color palette-index | raw-hex flag bits, base64url. Decode failures fall back to a random avatar. Config arrays are now append-only (indices live in shared links) — documented in the file header; the version nibble covers future breaking changes.
  • Worker script (first non-assets-only deploy): serves the SPA shell for code paths and GET /api/options (valid styles/palettes as JSON, CORS * — also groundwork for the LLM/API PR). run_worker_first with asset-dir exclusions, because Cloudflare's asset layer otherwise answers browser navigations (Sec-Fetch-Mode: navigate) with its own 404 before the worker runs.
  • UX: address bar keeps the readable ?hair=... form (self-documenting, hand-constructable); Copy Link and the tweet intent use the short form. Long URLs keep working forever.

Verification

  • 127-case round-trip suite in Node: every style and palette color in every category, custom hex colors, max indices, garbage inputs → null
  • wrangler dev + headless browser: /EpCSCBgBgACA boots the SPA to the exact encoded avatar and normalizes the URL; Copy Link/tweet emit the short URL; /favicon.png 200; garbage and deep paths 404

⚠️ Do not merge — awaiting Brian's review.

🤖 Generated with Claude Code

Share buttons now emit personas.draftbit.com/<code> where the code is a
bit-packed base64url encoding of the avatar config (12 chars for
palette colors, 31 max with custom hex). No storage: the code is the
config. The address bar keeps the readable query-param form.

- shareUrl.js: v1 codec (4-bit version, per-category style indices,
  flagged palette-index-or-raw-hex colors); config arrays are now
  append-only, documented in the file header
- worker/index.js (new): serves the SPA shell for code paths, exposes
  GET /api/options (config JSON, CORS *), falls through to assets;
  run_worker_first with asset-dir exclusions so browser navigations
  reach the worker instead of the asset layer's own 404 handling
- Modal gets the short URL via prop for Copy Link and the tweet intent

Verified: 127-case codec round-trip suite in Node; wrangler dev in a
real browser (code decodes, URL normalizes, share buttons emit short
form, assets and 404s unaffected).

Co-Authored-By: Claude Fable 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

Development

Successfully merging this pull request may close these issues.

1 participant