@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@matdata/yasr",
3
3
  "description": "Yet Another SPARQL Resultset GUI",
4
- "version": "5.20.2",
4
+ "version": "5.20.3",
5
5
  "main": "build/yasr.min.js",
6
6
  "types": "build/ts/src/index.d.ts",
7
7
  "license": "MIT",
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) {
@@ -292,9 +292,21 @@ class Parser {
292
292
  };
293
293
  }
294
294
  if (summary) {
295
- //if data is set, it should be less than max limit. If not set, it's probably a response error that we'd like to store as well
296
- if (summary.data && summary.data.length > maxResponseSize) {
297
- return undefined;
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
  }