Skip to content

feat: shorter bookmarklet URLs (4.3.0) - #464

Merged
mobilemind merged 2 commits into
mainfrom
feat/refine-encoding
Sep 27, 2026
Merged

mobilemind merged 2 commits into
mainfrom
feat/refine-encoding

Conversation

@mobilemind

Copy link
Copy Markdown
Owner

Summary

  • Leave :=,/;$@+? unescaped in javascript: bookmarklet URLs. They are legal in URL fragments and inert in HTML href values and Markdown link destinations.
  • Total dist size drops 11,895 → 10,749 bytes (−9.6%). UtmStrip −534, Linklighter −180, x-man −90, unskim −74.
  • encodeBookmarklet / validateEncodedBookmarklet in scripts/utils.js self-validate every build (WHATWG URL round trip, allowlist, balanced parens). A leading / stays encoded and unbalanced or deeply nested parens are encoded.
  • update-readme.js now uses a function replacer, so $', $& and $1 in code can't corrupt README.md.
  • New scripts/test-encoding.js (31 checks, including all 21 dist files), wired into npm test.
  • All 21 bookmarklets get a patch bump (every dist file changed); project version 4.3.0. Also includes the @types/node ~26.6.3 bump.

Still encoded: \ & < > " # % \`` and * _(Markdown emphasis);{}[]|^` left alone for a future iteration.

Test plan

  • npm test (78/78 utmstrip, 31 encoding, verify-build)
  • npx eslint . and npm run lint:md
  • cmark-gfm and kramdown renderings of README: 42/42 hrefs match dist/
  • git diff README.md shows only links, versions and the new notes
  • Safari: UtmStrip 2.3.3 strips params (the th=1 in the address bar is Amazon re-adding it on reload; clipboard copy is clean)
  • Safari: Linklighter works; Setup link keeps ,/;$@+? literal after copy

🤖 Generated with Claude Code

Leave `:=,/;$@+?` unescaped in bookmarklet URLs. They are legal in URL
fragments and inert in HTML attributes and Markdown link destinations.
Total dist size drops 11,895 -> 10,749 bytes (-9.6%); UtmStrip -534.

- Add encodeBookmarklet/validateEncodedBookmarklet to scripts/utils.js
  (keeps leading "/" encoded, encodes parens if unbalanced or >32 deep,
  self-validates with a WHATWG URL round trip)
- Use a function replacer in update-readme.js so `$` in code can't be
  treated as a replacement pattern
- Add scripts/test-encoding.js and run it from `npm test`
- Patch-bump all 21 bookmarklets; bump project to 4.3.0
- Bump @types/node to ~26.6.3

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Comment thread scripts/test-encoding.js Dismissed
Comment thread scripts/utils.js Dismissed
npm ci failed in CI because the lockfile still pinned @types/node 26.6.2.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mobilemind
mobilemind merged commit f4686d1 into main Sep 27, 2026
6 checks passed
@mobilemind
mobilemind deleted the feat/refine-encoding branch September 27, 2026 03:18
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.

2 participants