From df7338b32a3fffcb4b172b64cd8a74ca867b6f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s=20Calzado?= Date: Wed, 20 Oct 2021 10:23:20 +0200 Subject: [PATCH 1/2] Check atttributions text before loading them --- src/geo/ui/attribution/attribution-view.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/geo/ui/attribution/attribution-view.js b/src/geo/ui/attribution/attribution-view.js index d22485520e..6f03661c52 100644 --- a/src/geo/ui/attribution/attribution-view.js +++ b/src/geo/ui/attribution/attribution-view.js @@ -31,7 +31,12 @@ module.exports = View.extend({ }, render: function () { - var attributions = _.compact(this.map.get('attribution')).join(', '); + var attributionsSet = [...new Set(this.map.get('attribution'))]; + var attributions = _.compact(attributionsSet) + .join(', ') + .replace(/\s{2,}/g, ' ') + .replace(/\s,/g, ',') + .replace(/\,{2,}/g, ','); var isGMaps = this.map.get('provider') !== 'leaflet'; this.$el.html( template({ @@ -46,7 +51,7 @@ module.exports = View.extend({ _initBinds: function () { this.model.bind('change:visible', function (mdl, isVisible) { - this[ isVisible ? '_showAttributions' : '_hideAttributions' ](); + this[isVisible ? '_showAttributions' : '_hideAttributions'](); }, this); this.map.bind('change:attribution', this.render, this); this.add_related_model(this.map); From c9a977415a2d4ff9a5bbb378214039fc2c6d9e83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s=20Calzado?= Date: Mon, 25 Oct 2021 11:20:59 +0200 Subject: [PATCH 2/2] Update check before rendering attributions --- src/geo/ui/attribution/attribution-view.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/geo/ui/attribution/attribution-view.js b/src/geo/ui/attribution/attribution-view.js index 6f03661c52..e882c723b9 100644 --- a/src/geo/ui/attribution/attribution-view.js +++ b/src/geo/ui/attribution/attribution-view.js @@ -31,12 +31,11 @@ module.exports = View.extend({ }, render: function () { + var emptyStringRegExp = new RegExp(/[A-z]/g); var attributionsSet = [...new Set(this.map.get('attribution'))]; var attributions = _.compact(attributionsSet) - .join(', ') - .replace(/\s{2,}/g, ' ') - .replace(/\s,/g, ',') - .replace(/\,{2,}/g, ','); + .filter(attribution => emptyStringRegExp.test(attribution)) + .join(', '); var isGMaps = this.map.get('provider') !== 'leaflet'; this.$el.html( template({