Skip to content

Commit

Permalink
Remove potential \r from Windows line endings before computing a hash
Browse files Browse the repository at this point in the history
  • Loading branch information
remarcmij committed Nov 5, 2024
1 parent c08e0eb commit d9cb252
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test-runner/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export function computeHash(exercisePath: string): string {
.replace(/\\/g, '/');
const filePaths = fg.sync(globSpec);
for (const filePath of filePaths) {
const content = fs.readFileSync(filePath, 'utf8');
// Note: convert potential Windows \r\n line endings to \n
// to avoid hash mismatches
const content = fs.readFileSync(filePath, 'utf8').replaceAll('\r\n', '\n');
sha256sum.update(content);
}
return sha256sum.digest('hex');
Expand Down

0 comments on commit d9cb252

Please sign in to comment.