Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Commit da98735

Browse files
committed
Fix line endings regex
1 parent d54bbc2 commit da98735

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/pr-info.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,10 @@ function makeJsonCheckerFromCore(requiredForm: any, ignoredKeys: string[], requi
492492
? prettier.format(JSON.stringify(suggestion), { tabWidth: 4, filepath: ".json" })
493493
: JSON.stringify(suggestion, undefined, 4) + "\n"
494494
).split(/^/m);
495-
const lines = newText.split(/^/m);
495+
// "^" will match inside LineTerminatorSequence so
496+
// "\r\n".split(/^/m) is two lines. Sigh.
497+
// https://tc39.es/ecma262/#_ref_7303:~:text=the%20character%20Input%5Be%20%2D%201%5D%20is%20one%20of%20LineTerminator
498+
const lines = newText.replace(/\r\n/g, "\n").split(/^/m);
496499
// When suggestionLines is empty, that suggests removing all
497500
// of the different lines
498501
let startLine = 1;

0 commit comments

Comments
 (0)