Last 12 weeks ยท 3 commits
5 of 6 standards met
Describe the bug If you add rules as : then will match as : but if you add them as : then the same text will match as : A fix could be to sort the keys by size (to have the "closest" match first) Reproduction https://stackblitz.com/edit/stackblitz-starters-zc8y2r?file=test.md System Info Used Package Manager pnpm Validations [X] Follow our Code of Conduct [X] Read the Contributing Guide. [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate. [X] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead. [X] The provided reproduction is a minimal reproducible of the bug.
Summary Regex alternation is leftmost-wins, not longest-wins. So when the dictionary contains both and , results depended on dictionary insertion order: Against input : Before: , then inside โ , leaving โ After: longer key tried first โ , โ Sort keys by length descending when building the regex so the more specific rule wins, regardless of dictionary order. Test plan [x] โ 6 tests pass (2 new cases for both dictionary orderings) [x] [x] Fixes #158
Repository: antfu/case-police. Description: ๐จ Make the case correct, PLEASE! Stars: 1428, Forks: 91. Primary language: TypeScript. Languages: TypeScript (97.9%), JavaScript (1.3%), Vue (0.8%). License: MIT. Latest release: v2.2.1 (2mo ago). Open PRs: 4, open issues: 3. Last activity: 2mo ago. Community health: 85%. Top contributors: antfu, PinkChampagne17, holazz, webfansplz, wey-gu, Evavic44, sajadhsm, rubiin, Justineo, thecuvii and others.