Skip to content

Commit 55a95d3

Browse files
committed
Add test for newline sentence
1 parent a7ed34a commit 55a95d3

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/title-case/src/index.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ const TEST_CASES: [string, string, Options?][] = [
148148
["21st century", "21st Century"],
149149
["foo\nbar", "Foo\nBar"],
150150
["foo\nbar\nbaz", "Foo\nBar\nBaz"],
151+
["friday\nthe 13th", "Friday\nThe 13th"],
151152
];
152153

153154
describe("swap case", () => {

packages/title-case/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const TOKENS = /(\S+)|\s+/g;
1+
const TOKENS = /(\S+)|\s/g;
22
const IS_SPECIAL_CASE = /[\.#][\p{L}\p{N}]/u; // #tag, example.com, etc.
33
const IS_MANUAL_CASE = /\p{Ll}(?=[\p{Lu}])/u; // iPhone, iOS, etc.
44
const ALPHANUMERIC_PATTERN = /[\p{L}\p{N}]+/gu;
@@ -89,6 +89,7 @@ export function titleCase(
8989

9090
if (!token) {
9191
result += match;
92+
if (match === "\n" || match === "\r") isNewSentence = true;
9293
continue;
9394
}
9495

0 commit comments

Comments
 (0)