Skip to content

Commit

Permalink
fixed filname checking in export class
Browse files Browse the repository at this point in the history
  • Loading branch information
LCluber committed Apr 10, 2019
1 parent dc5d871 commit 5e4e1b2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 0.1.10 (April 10th 2019)
-----------------------------
* fixed csv export with better filename checking

Version 0.1.9 (April 09th 2019)
-----------------------------
* fixed csv export with special characters
Expand Down
6 changes: 3 additions & 3 deletions dist/csvx.iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ var CSVx = (function (exports) {
return false;
}

if (!filename.trim().length) {
if (!filename) {
filename = 'export';
}

Expand All @@ -992,7 +992,7 @@ var CSVx = (function (exports) {
this.log.info(filename + ' labels ready');
}

table += encodeURIComponent(this.createTable(_data));
table += this.createTable(_data);
this.log.info(filename + ' table ready');
this.download(table, filename);
return true;
Expand Down Expand Up @@ -1050,7 +1050,7 @@ var CSVx = (function (exports) {
table += this.createRow(parsedRow);
}

return table;
return encodeURIComponent(table);
};

Export.createLabels = function createLabels(data) {
Expand Down
2 changes: 1 addition & 1 deletion dist/csvx.iife.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/csvx.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Export {
if (!Is.object(data[0]) && !Is.json(data[0])) {
return false;
}
if (!filename.trim().length) {
if (!filename) {
filename = 'export';
}
if (options) {
Expand All @@ -48,7 +48,7 @@ class Export {
}
this.log.info(filename + ' labels ready');
}
table += encodeURIComponent(this.createTable(data));
table += this.createTable(data);
this.log.info(filename + ' table ready');
this.download(table, filename);
return true;
Expand Down Expand Up @@ -82,7 +82,7 @@ class Export {
}
table += this.createRow(parsedRow);
}
return table;
return encodeURIComponent(table);
}
static createLabels(data) {
let labels = Is.json(data[0]) || data[0];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lcluber/csvxjs",
"version": "0.1.9",
"version": "0.1.10",
"description": "CSV Export library written in TypeScript.",
"keywords": [],
"homepage": "http://csvxjs.lcluber.com",
Expand Down
6 changes: 3 additions & 3 deletions src/ts/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class Export {
if (!Is.object(data[0]) && !Is.json(data[0])) {
return false;
}
if (!filename.trim().length) {
if (!filename) {
filename = 'export';
}
if (options) {
Expand All @@ -39,7 +39,7 @@ export class Export {
}
this.log.info(filename + ' labels ready');
}
table += encodeURIComponent(this.createTable(data));
table += this.createTable(data);
this.log.info(filename + ' table ready');
this.download(table, filename);
return true;
Expand Down Expand Up @@ -76,7 +76,7 @@ export class Export {
}
table += this.createRow(parsedRow);
}
return table;
return encodeURIComponent(table);
}

private static createLabels( data: Object[]|string[] ): string {
Expand Down

0 comments on commit 5e4e1b2

Please sign in to comment.