From ff89125c80b3b82903b28027c8b02dad207aa604 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Sat, 23 Sep 2023 20:48:45 +0200 Subject: [PATCH] Redirect to canonical URL when people share the ?edit link --- umap/static/umap/js/umap.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index f363ec88..a7a301bd 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -263,7 +263,12 @@ L.U.Map.include({ this.onceDataLoaded(function () { const slug = L.Util.queryString('feature') if (slug && this.features_index[slug]) this.features_index[slug].view() - if (L.Util.queryString('edit')) this.enableEdit() + if (L.Util.queryString('edit')) { + if (this.hasEditMode()) this.enableEdit() + // Sometimes users share the ?edit link by mistake, let's redirect + // to canonical in this case + else window.location = window.location.pathname + } if (L.Util.queryString('download')) this.download() })