Skip to content

Commit

Permalink
fix: Remove extra space character in mode withBOM: true #190 (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-zahariev authored and knownasilya committed Aug 15, 2017
1 parent d7ad29f commit e8b6f6b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/json2csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ function createColumnContent(params, str) {
});
// Add BOM character if required
if (params.withBOM) {
str = '\ufeff ' + str;
str = '\ufeff' + str;
}

return str;
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/csv/withBOM.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"Audi",0,"blue",
"BMW",15000,"red","manual"
"Mercedes",20000,"yellow",
"Citroën",30000,"green",
"Citroën",30000,"green",
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down

0 comments on commit e8b6f6b

Please sign in to comment.