fix(core): update

This commit is contained in:
Philipp Kunz 2019-12-15 18:15:03 +00:00
parent e7f06a7f44
commit 5f49532fc2
3 changed files with 28 additions and 20 deletions

25
package-lock.json generated
View File

@ -279,9 +279,9 @@
} }
}, },
"@pushrocks/smartstring": { "@pushrocks/smartstring": {
"version": "3.0.14", "version": "3.0.17",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartstring/-/smartstring-3.0.14.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartstring/-/smartstring-3.0.17.tgz",
"integrity": "sha512-hN3IwTb5VBUis8Z5U5U6dDCnap6zBmkc9/IVx8lxAbsxl5TYQ4RiYlJ2JM4tih7EdE80ZeSdpprzChYrWmSwDg==", "integrity": "sha512-60JQptpgw+PjxoC5Gx+Y9m3/dtMstHC5ElpdJhIlbJ7dQV7LkCGSonLAG+NZhPbvrhow2KZ3fob8stW0Iuy3JQ==",
"requires": { "requires": {
"crypto-random-string": "^3.0.1", "crypto-random-string": "^3.0.1",
"js-base64": "^2.5.1", "js-base64": "^2.5.1",
@ -304,21 +304,22 @@
} }
}, },
"@pushrocks/tapbundle": { "@pushrocks/tapbundle": {
"version": "3.0.13", "version": "3.2.0",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-3.0.13.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-3.2.0.tgz",
"integrity": "sha512-23O4UMBafCuD+RnUlXNvtT9DGbL1HMD+xZE1Zcr7Ll7WvgxUgRQQfk9kq6qbLLbjaRe1J2Ijsgh1HuZbBaucLQ==", "integrity": "sha512-xnKIGe7NJqxWBaFeKIEXShDjV2wap1XJqmlp3m1MKqmIF62vRpZnkzpyE1ZAoNwiYQmIsXIpvP/PDv+iPevPfw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@pushrocks/early": "^3.0.3", "@pushrocks/early": "^3.0.3",
"@pushrocks/smartdelay": "^2.0.3", "@pushrocks/smartdelay": "^2.0.3",
"@pushrocks/smartfile": "^7.0.6",
"@pushrocks/smartpromise": "^3.0.2", "@pushrocks/smartpromise": "^3.0.2",
"smartchai": "^2.0.1" "smartchai": "^2.0.1"
} }
}, },
"@types/chai": { "@types/chai": {
"version": "4.2.3", "version": "4.2.7",
"resolved": "https://verdaccio.lossless.one/@types%2fchai/-/chai-4.2.3.tgz", "resolved": "https://verdaccio.lossless.one/@types%2fchai/-/chai-4.2.7.tgz",
"integrity": "sha512-VRw2xEGbll3ZiTQ4J02/hUjNqZoue1bMhoo2dgM2LXjDdyaq4q80HgBDHwpI0/VKlo4Eg+BavyQMv/NYgTetzA==", "integrity": "sha512-luq8meHGYwvky0O7u0eQZdA7B4Wd9owUCqvbw2m3XCrCU8mplYOujMBbvyS547AxJkC+pGnd0Cm15eNxEUNU8g==",
"dev": true "dev": true
}, },
"@types/chai-as-promised": { "@types/chai-as-promised": {
@ -395,9 +396,9 @@
"dev": true "dev": true
}, },
"@types/node": { "@types/node": {
"version": "12.7.12", "version": "12.12.17",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.7.12.tgz", "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.12.17.tgz",
"integrity": "sha512-KPYGmfD0/b1eXurQ59fXD1GBzhSQfz6/lKBxkaHX9dKTzjXbK68Zt7yGUxUsCS1jeTy/8aL+d9JEr+S54mpkWQ==", "integrity": "sha512-Is+l3mcHvs47sKy+afn2O1rV4ldZFU7W8101cNlOd+MRbjM4Onida8jSZnJdTe/0Pcf25g9BNIUsuugmE6puHA==",
"dev": true "dev": true
}, },
"@types/through2": { "@types/through2": {

View File

@ -17,12 +17,12 @@
"@gitzone/tsrun": "^1.2.8", "@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.28", "@gitzone/tstest": "^1.0.28",
"@pushrocks/smartfile": "^7.0.6", "@pushrocks/smartfile": "^7.0.6",
"@pushrocks/tapbundle": "^3.0.13", "@pushrocks/tapbundle": "^3.2.0",
"@types/node": "^12.7.12" "@types/node": "^12.12.17"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartstring": "^3.0.14" "@pushrocks/smartstring": "^3.0.17"
}, },
"files": [ "files": [
"ts/*", "ts/*",

View File

@ -55,6 +55,8 @@ export class Csv {
public keyFrame: string = null; public keyFrame: string = null;
public data: any[]; public data: any[];
private base64RecognitionPrefix = '####12345####';
public options: ICsvConstructorOptions = { public options: ICsvConstructorOptions = {
headers: true, headers: true,
unquote: true unquote: true
@ -71,7 +73,7 @@ export class Csv {
csvStringToParse = csvStringToParse.replace( csvStringToParse = csvStringToParse.replace(
/"(.*?)"/gi, /"(.*?)"/gi,
(match, p1, offset, originalString) => { (match, p1, offset, originalString) => {
return plugins.smartstring.base64.encode(match); return this.base64RecognitionPrefix + plugins.smartstring.base64.encode(match);
} }
); );
} }
@ -137,8 +139,9 @@ export class Csv {
this.headers = headerRow.split(this.keyFrame); this.headers = headerRow.split(this.keyFrame);
if (this.options.unquote) { if (this.options.unquote) {
const unquotedHeaders: string[] = []; const unquotedHeaders: string[] = [];
for (const header of this.headers) { for (let header of this.headers) {
if (plugins.smartstring.type.isBase64(header)) { if (header.startsWith(this.base64RecognitionPrefix)) {
header = header.replace(this.base64RecognitionPrefix, '');
unquotedHeaders.push(plugins.smartstring.base64.decode(header).replace(/['"]+/g, '')); unquotedHeaders.push(plugins.smartstring.base64.decode(header).replace(/['"]+/g, ''));
} else { } else {
unquotedHeaders.push(header); unquotedHeaders.push(header);
@ -155,8 +158,12 @@ export class Csv {
let resultJson: any = {}; let resultJson: any = {};
for (let i = 0; i < neededIterations; i++) { for (let i = 0; i < neededIterations; i++) {
let value = dataArray[i]; let value = dataArray[i];
if (this.options.unquote && plugins.smartstring.type.isBase64(value)) { if (this.options.unquote && value.startsWith(this.base64RecognitionPrefix)) {
value = plugins.smartstring.base64.decode(value).replace(/['"]+/g, '').replace(/['"]+/g, ''); value = value.replace(this.base64RecognitionPrefix, '');
value = plugins.smartstring.base64
.decode(value)
.replace(/['"]+/g, '')
.replace(/['"]+/g, '');
} }
resultJson[this.headers[i]] = value; resultJson[this.headers[i]] = value;
} }