Fix null dereference in helpers.getPreferredLineEnding when running in browser (platform unknown, process object not available) and input string does not contain line endings.

This commit is contained in:
David Anson 2022-05-04 22:09:11 -07:00
parent 580b7ed020
commit 295e481552
4 changed files with 51 additions and 3 deletions

View file

@ -390,6 +390,14 @@ test("forEachInlineCodeSpan", (t) => {
});
});
test("getPlatformIdentifier", (t) => {
t.plan(4);
t.is(helpers.getPlatformIdentifier("custom", process), "custom");
t.is(helpers.getPlatformIdentifier("custom", null), "custom");
t.is(helpers.getPlatformIdentifier(null, process), process.platform);
t.is(helpers.getPlatformIdentifier(null, null), "unknown");
});
test("getPreferredLineEnding", (t) => {
t.plan(19);
const testCases = [