diff --git a/src/responses/DiffSummary.js b/src/responses/DiffSummary.js index cd79410d..cf8b3a24 100644 --- a/src/responses/DiffSummary.js +++ b/src/responses/DiffSummary.js @@ -65,7 +65,7 @@ function textFileChange (line, files) { } function binaryFileChange (line, files) { - line = line.match(/^(.+) \| Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)$/); + line = line.match(/^(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)$/); if (line) { files.push({ file: line[1].trim(), diff --git a/test/unit/test-diff.js b/test/unit/test-diff.js index abc22cb1..acc2ca95 100644 --- a/test/unit/test-diff.js +++ b/test/unit/test-diff.js @@ -135,4 +135,18 @@ exports.diff = { test.done(); }, + + 'recognises binary files' (test) { + + const summary = DiffSummary.parse(` + some/image.png | Bin 0 -> 9806 bytes + 1 file changed, 1 insertion(+) + `); + + test.deepEqual(summary.files, [ + { file: 'some/image.png', before: 0, after: 9806, binary: true }, + ]); + + test.done(); + }, };