Skip to content

Commit fed5b1c

Browse files
committed
normalise line-endings on read
1 parent b7ca6c8 commit fed5b1c

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/config/loadSaltFile.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ type LoadSaltFileOutput = { success: true; data: string; message?: string } | {
3434
export function loadSaltFile({ saltFilePath, validatorRegexp = DEFAULT_VALIDATOR_REGEXP }: LoadSaltFileInput): LoadSaltFileOutput {
3535

3636
// TODO: potentially clean up line endings and whitespace here
37-
const saltData = attemptToReadFileData(saltFilePath, SALT_FILE_ENCODING);
38-
if (!saltData) return { success: false, message: `[ERROR] Unable to read salt file at path: ${saltFilePath}` };
39-
37+
const buf = attemptToReadFileData(saltFilePath, SALT_FILE_ENCODING);
38+
if (!buf) return { success: false, message: `[ERROR] Unable to read salt file at path: ${saltFilePath}` };
39+
40+
const saltData = buf.toString().replace(/\r\n/g, "\n");
41+
4042
// check if the structure is correct for the file
4143
const CHECK_RX = new RegExp(validatorRegexp);
4244
if (!CHECK_RX.test(saltData)) {

0 commit comments

Comments
 (0)