@matdata/yasr 5.20.2 → 5.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/ts/src/index.js +10 -0
- package/build/ts/src/index.js.map +1 -1
- package/build/ts/src/parsers/index.js +16 -2
- package/build/ts/src/parsers/index.js.map +1 -1
- package/build/yasr.min.css.map +1 -1
- package/build/yasr.min.js +2 -2
- package/build/yasr.min.js.map +3 -3
- package/package.json +1 -1
- package/src/index.ts +9 -0
- package/src/parsers/index.ts +15 -3
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -551,6 +551,11 @@ export class Yasr extends EventEmitter {
|
|
|
551
551
|
}
|
|
552
552
|
|
|
553
553
|
public getResponseFromStorage() {
|
|
554
|
+
if (this.config.maxPersistentResponseSize <= 0) {
|
|
555
|
+
const storageId = this.getStorageId(this.config.persistenceLabelResponse);
|
|
556
|
+
if (storageId) this.storage.remove(storageId);
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
554
559
|
const storageId = this.getStorageId(this.config.persistenceLabelResponse);
|
|
555
560
|
if (storageId) {
|
|
556
561
|
return this.storage.get(storageId);
|
|
@@ -581,6 +586,10 @@ export class Yasr extends EventEmitter {
|
|
|
581
586
|
}
|
|
582
587
|
private storeResponse() {
|
|
583
588
|
const storageId = this.getStorageId(this.config.persistenceLabelResponse);
|
|
589
|
+
if (storageId && this.config.maxPersistentResponseSize <= 0) {
|
|
590
|
+
this.storage.remove(storageId);
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
584
593
|
if (storageId && this.results) {
|
|
585
594
|
const storeObj = this.results.getAsStoreObject(this.config.maxPersistentResponseSize);
|
|
586
595
|
if (storeObj && !storeObj.error) {
|
package/src/parsers/index.ts
CHANGED
|
@@ -292,9 +292,21 @@ class Parser {
|
|
|
292
292
|
};
|
|
293
293
|
}
|
|
294
294
|
if (summary) {
|
|
295
|
-
//
|
|
296
|
-
if (summary.data
|
|
297
|
-
|
|
295
|
+
// If data is set, it should be less than max limit. For non-strings, compare serialized size.
|
|
296
|
+
if (summary.data !== undefined) {
|
|
297
|
+
let dataSize = 0;
|
|
298
|
+
if (typeof summary.data === "string") {
|
|
299
|
+
dataSize = summary.data.length;
|
|
300
|
+
} else {
|
|
301
|
+
try {
|
|
302
|
+
dataSize = JSON.stringify(summary.data).length;
|
|
303
|
+
} catch (_e) {
|
|
304
|
+
return undefined;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (dataSize > maxResponseSize) {
|
|
308
|
+
return undefined;
|
|
309
|
+
}
|
|
298
310
|
}
|
|
299
311
|
return summary;
|
|
300
312
|
}
|