From 37a09c6012ad243366d25b7bf4a60a9b955dc9a4 Mon Sep 17 00:00:00 2001 From: Nater Jorde Date: Mon, 25 Mar 2019 16:18:57 -0500 Subject: [PATCH] use JSON.stringify for lookup keys of complex strings --- source/lib/workbook/workbook.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/lib/workbook/workbook.js b/source/lib/workbook/workbook.js index f124927..cc171e9 100644 --- a/source/lib/workbook/workbook.js +++ b/source/lib/workbook/workbook.js @@ -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;