fix(clean): strip surrounding whitespace#125
Conversation
clean() normalized unicode and removed the given separator characters but left surrounding whitespace outside that set (newlines, tabs) intact, so validate() rejected otherwise-valid copy-pasted input. A few modules worked around this with a manual .trim(); most did not. Trim in clean() so every compact()/validate() handles surrounding whitespace uniformly.
There was a problem hiding this comment.
Code Review
This pull request updates the clean utility function in src/_util/clean.ts to trim surrounding whitespace (such as newlines and tabs) from the output, ensuring that validators can handle copy-pasted input with trailing or leading whitespace. It also adds corresponding unit tests in __test__/clean.test.ts and __test__/no.test.ts to verify this behavior. There are no review comments, so no additional feedback is provided.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
clean()normalizes Unicode artifacts and removes the separator characters it is given, but left surrounding whitespace outside that set (newlines, tabs) intact. Since everycompact()— and therefore everyvalidate()— builds onclean(), a value padded with a stray newline or tab (common in copy-paste) failed the length/format checks and was wrongly rejected.A few modules already worked around this with a manual
.trim()in theircompact; most did not, so the behavior was inconsistent across jurisdictions.This trims in
clean()so everycompact()/validate()handles surrounding whitespace uniformly. Internal characters and the existing separator-stripping are unchanged.Added a focused
cleanunit test and an end-to-endno.orgnrcase; the full suite passes.