From e8b6f6be8aad150c618d6e460bb4e3edc25dc016 Mon Sep 17 00:00:00 2001 From: Daniel Zahariev Date: Tue, 15 Aug 2017 16:38:28 +0300 Subject: [PATCH] fix: Remove extra space character in mode withBOM: true #190 (#194) --- lib/json2csv.js | 2 +- test/fixtures/csv/withBOM.csv | 2 +- test/index.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/json2csv.js b/lib/json2csv.js index 1cfb898f..106fdc2f 100644 --- a/lib/json2csv.js +++ b/lib/json2csv.js @@ -303,7 +303,7 @@ function createColumnContent(params, str) { }); // Add BOM character if required if (params.withBOM) { - str = '\ufeff ' + str; + str = '\ufeff' + str; } return str; diff --git a/test/fixtures/csv/withBOM.csv b/test/fixtures/csv/withBOM.csv index feaa02ae..b9077d55 100644 --- a/test/fixtures/csv/withBOM.csv +++ b/test/fixtures/csv/withBOM.csv @@ -2,4 +2,4 @@ "Audi",0,"blue", "BMW",15000,"red","manual" "Mercedes",20000,"yellow", -"Citroën",30000,"green", +"Citroën",30000,"green", \ No newline at end of file diff --git a/test/index.js b/test/index.js index 4d4a9b50..702c52ef 100644 --- a/test/index.js +++ b/test/index.js @@ -722,8 +722,8 @@ async.parallel(loadFixtures(csvFixtures), function (err) { data: jsonSpecialCharacters, withBOM: true }); - // Compare csv length to check if the BOM character and the space after are present - t.equal(csv.length, csvFixtures.default.length + 2); + // Compare csv length to check if the BOM character is present + t.equal(csv.length, csvFixtures.default.length + 1); t.equal(csv.length, csvFixtures.withBOM.length); t.end(); });