Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
use JSON.stringify for lookup keys of complex strings
Browse files Browse the repository at this point in the history
  • Loading branch information
natergj committed Mar 25, 2019
1 parent 52b956f commit 37a09c6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions source/lib/workbook/workbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,11 @@ class Workbook {
* @returns {Number} index of the string in the shared strings array
*/
getStringIndex(val) {
const target = this.sharedStringLookup.get(val);
const lookupKey = typeof val === "string" ? val : JSON.stringify(val);
const target = this.sharedStringLookup.get(lookupKey);
if (_isUndefined(target)) {
const index = this.sharedStrings.push(val) - 1;
this.sharedStringLookup.set(val, index);
this.sharedStringLookup.set(lookupKey, index);
return index;
} else {
return target;
Expand Down

0 comments on commit 37a09c6

Please sign in to comment.