Repository navigation
Fix offer letter filename for accented names - #180
Shashankojha-ai wants to merge 1 commit into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Someone is attempting to deploy a commit to the Geetansh Goyal's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
✅ Thanks @Shashankojha-ai — the description looks good now. This PR is no longer at risk of being closed. |
📸 How this looksBuilt from this PR, so you can see the change without checking it out.
|
MehulNegi
left a comment
There was a problem hiding this comment.
Checked out the branch and ran it. npx vitest run lib/offer-letter.test.ts passes 3/3, and npm test passes 124/124. The accented case from #87 works now (Ádítí Sharma -> Aditi-Sharma), and keeping this separate from slugify makes sense since that one lowercases and cuts at 60 chars.
Question: why does this add server-only to package.json? lib/offer-letter.ts already imported it on main without it being listed, and the new test imports lib/filename.ts, which doesn't pull it in. I may be missing something about how Next resolves it, but it looks unrelated to the filename change.
| name | ||
| .trim() | ||
| .normalize("NFKD") | ||
| .replace(/[\u0300-\u036f]/g, "") |
There was a problem hiding this comment.
This only catches letters that NFKD splits into base + combining mark. Ones it doesn't split still get dropped. I ran a few through sanitizeFilenameSlug:
Łukasz Nowak -> ukasz-Nowak
Søren Kierkegaard -> S-ren-Kierkegaard
Đặng Văn Lâm -> ang-Van-Lam
Weiß -> Wei
That's the same mangling #87 describes, just for different letters. A small map before the [^a-zA-Z0-9] replace (ł->l, ø->o, đ->d, ß->ss, æ->ae, œ->oe) would cover the common ones, plus a test for one of them. If that's out of scope for this issue, a test that pins the current output would at least make the limit visible.




Fixes #87
What
Normalize names with NFKD and strip combining marks before creating offer-letter PDF filenames. This preserves accented Latin characters as ASCII and keeps the
memberfallback for blank or symbol-only names.How I tested
npm run lint— passed (existing warnings only).npm test— passed, 124 tests.npm run build— passed.