diff options
Diffstat (limited to 'ext/bg/js')
-rw-r--r-- | ext/bg/js/util.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index 8175fdff..93bb7047 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -16,8 +16,20 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -function utilIsolate(data) { - return JSON.parse(JSON.stringify(data)); +function utilIsolate(value) { + if (value === null) { return null; } + + switch (typeof value) { + case 'boolean': + case 'number': + case 'string': + case 'bigint': + case 'symbol': + return value; + } + + const stringValue = JSON.stringify(value); + return typeof stringValue === 'string' ? JSON.parse(stringValue) : null; } function utilBackgroundIsolate(data) { |