From 387a865e0954cea32b4bc6e15032b8606e41ba2c Mon Sep 17 00:00:00 2001 From: Sandro Mani Date: Wed, 28 Feb 2024 12:18:56 +0100 Subject: [PATCH] Robustness fix --- plugins/MapFilter.jsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/MapFilter.jsx b/plugins/MapFilter.jsx index 7e8409076..b2b5291ae 100644 --- a/plugins/MapFilter.jsx +++ b/plugins/MapFilter.jsx @@ -220,9 +220,18 @@ class MapFilter extends React.Component { if (this.state.geomFilter.geom) { permalinkState.__geomfilter = this.state.geomFilter.geom.coordinates; } - permalinkState.__custom = Object.values(this.state.customFilters).filter(entry => entry.active).map(entry => ({ - title: entry.title, layer: entry.layer, expr: JSON.parse(entry.expr) - })); + permalinkState.__custom = Object.values(this.state.customFilters).map(entry => { + if (!entry.active) { + return null; + } + let expr = null; + try { + expr = JSON.parse(entry.expr); + } catch (e) { + return null; + } + return {title: entry.title, layer: entry.layer, expr: expr}; + }).filter(Boolean); this.props.setPermalinkParameters({f: JSON.stringify(permalinkState)}); } }