Files
clean-architecture-frontend…/tests/unit
DongHyeonkaandClaude Opus 5.5 d67fe1ab35 perf(browser-files): truncate filenames in one pass and sanitize once (Q-6.2-10)
sanitizeSuggestedFileName dropped one code point at a time and re-encoded the
whole name each round, so a 100k-character server-supplied name took ~10^10
steps. truncateUtf8 now walks the code points once, counting UTF-8 bytes, and
cuts at the longest fitting prefix (trailing whitespace trimmed, as before).
The fallback base name uses the same helper. deliver() also sanitized the
name twice (validation, then again for use); validateDownloadInput now
returns the sanitized name and deliverActive uses it.

Verified: new unit test pins results for ASCII, Hangul, emoji and the
whitespace-trim case, and asserts a 5k-character name needs <10
TextEncoder.encode calls (RED before: 4827). Lane gates pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 13:39:59 +09:00
..