fix(ui): keep truncateWithEndVisible code-point-safe in short-width fallback#9047
Conversation
🦋 Changeset detectedLatest commit: 931e3cf The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
effb3f1 to
931e3cf
Compare
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/electron
@clerk/electron-passkeys
@clerk/eslint-plugin
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
API Changes Report
Summary
No API Changes DetectedAll packages have stable APIs with no detected changes. Report generated by Break Check Last ran on |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Repository UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthrough
ChangesSurrogate-safe truncation fix
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
truncateWithEndVisiblekeeps the start and end of a string and puts an ellipsis in the middle. The main path builds the result fromArray.from(str), so it slices on code points and never breaks a character. The short-width fallback (taken whenmaxLength <= endChars + 3) instead returnedELLIPSIS + str.slice(-endChars), which slices on UTF-16 code units.For characters outside the BMP (CJK Extension B kanji, emoji) each character is a surrogate pair of two code units, so
str.slice(-endChars)can cut one in half and leave a lone surrogate:The fallback now slices by code point, the same way the main path already does. ASCII inputs are unaffected and the existing tests still pass. Added a test covering the fallback with astral characters.
Re-creates #9029 from a branch in this repo so CI runs with the necessary secrets. Authored by @greymoth-jp; original commit authorship is preserved in git history.
Summary by CodeRabbit