From f4d96588ed06f887b0a1fbf8183985ad2c4c493f Mon Sep 17 00:00:00 2001 From: mulfvik Date: Fri, 24 May 2024 08:29:09 +0200 Subject: [PATCH 1/3] Fix map name parsing in permalink store getState() function --- src/permalink/permalinkstore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/permalink/permalinkstore.js b/src/permalink/permalinkstore.js index 346c42796..a2d13048f 100644 --- a/src/permalink/permalinkstore.js +++ b/src/permalink/permalinkstore.js @@ -104,7 +104,7 @@ permalinkStore.getState = function getState(viewer, isExtended) { .join(); } if (viewer.getMapName()) { - state.map = viewer.getMapName().split('.')[0]; + state.map = viewer.getMapName().split('.json')[0]; } Object.keys(additionalMapStateParams).forEach((key) => additionalMapStateParams[key](state)); From 20a23e3d3e7d52feb6d53b0079cbfdaef4e9f5fe Mon Sep 17 00:00:00 2001 From: mulfvik Date: Tue, 28 May 2024 20:06:42 +0200 Subject: [PATCH 2/3] Refactor permalinkStore.js to extract map name without .json extension This commit refactors permalinkStore.js to extract the map name without the .json extension. The code now uses the lastIndexOf method to find the last occurrence of the '.' character and extracts the substring before it. This improves the readability and maintainability of the code. --- src/permalink/permalinkstore.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/permalink/permalinkstore.js b/src/permalink/permalinkstore.js index a2d13048f..aa5000729 100644 --- a/src/permalink/permalinkstore.js +++ b/src/permalink/permalinkstore.js @@ -104,7 +104,8 @@ permalinkStore.getState = function getState(viewer, isExtended) { .join(); } if (viewer.getMapName()) { - state.map = viewer.getMapName().split('.json')[0]; + const lastPointIndex = viewer.getMapName().lastIndexOf('.'); + state.map = viewer.getMapName().substring(0, lastPointIndex); } Object.keys(additionalMapStateParams).forEach((key) => additionalMapStateParams[key](state)); From df717075dcbb58577f91d5f851b46abf95299343 Mon Sep 17 00:00:00 2001 From: mulfvik Date: Thu, 30 May 2024 10:06:14 +0200 Subject: [PATCH 3/3] Fix bug in permalinkstore.js for handling map names with periods. --- src/permalink/permalinkstore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/permalink/permalinkstore.js b/src/permalink/permalinkstore.js index aa5000729..391d5a3b0 100644 --- a/src/permalink/permalinkstore.js +++ b/src/permalink/permalinkstore.js @@ -103,7 +103,7 @@ permalinkStore.getState = function getState(viewer, isExtended) { state.pin = getPin().getGeometry().getCoordinates().map(coord => Math.round(coord)) .join(); } - if (viewer.getMapName()) { + if (viewer.getMapName() && viewer.getMapName().indexOf('.') !== -1) { const lastPointIndex = viewer.getMapName().lastIndexOf('.'); state.map = viewer.getMapName().substring(0, lastPointIndex); }