Skip to content

Commit

Permalink
SplitWords: Fix bug with casing (#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
bconnorwhite committed Jan 13, 2023
1 parent a82342a commit 98ab903
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/split-words.d.ts
Expand Up @@ -33,7 +33,7 @@ export type SplitWords<
> = Sentence extends `${infer FirstCharacter}${infer RemainingCharacters}`
? FirstCharacter extends WordSeparators
// Skip word separator
? [...SkipEmptyWord<CurrentWord>, ...SplitWords<RemainingCharacters, LastCharacter>]
? [...SkipEmptyWord<CurrentWord>, ...SplitWords<RemainingCharacters>]
: LastCharacter extends ''
// Fist char of word
? SplitWords<RemainingCharacters, FirstCharacter, FirstCharacter>
Expand Down
3 changes: 3 additions & 0 deletions test-d/split-words.ts
Expand Up @@ -79,6 +79,9 @@ expectType<SplitWords<'Hello--world--'>>(['Hello', 'world']);
expectType<SplitWords<'hello__world___'>>(['hello', 'world']);
expectType<SplitWords<'___ hello -__ _world'>>(['hello', 'world']);
expectType<SplitWords<'__HelloWorld-HELLOWorld helloWORLD'>>(['Hello', 'World', 'HELLO', 'World', 'hello', 'WORLD']);
expectType<SplitWords<'hello WORLD lowercase'>>(['hello', 'WORLD', 'lowercase']);
expectType<SplitWords<'hello WORLD-lowercase'>>(['hello', 'WORLD', 'lowercase']);
expectType<SplitWords<'hello WORLD Uppercase'>>(['hello', 'WORLD', 'Uppercase']);

expectType<SplitWords<'item0'>>(['item', '0']);
expectType<SplitWords<'item01'>>(['item', '01']);
Expand Down

0 comments on commit 98ab903

Please sign in to comment.