Skip to content

Commit

Permalink
Fix map name parsing in permalink store getState() function (#2016)
Browse files Browse the repository at this point in the history
* Fix map name parsing in permalink store getState() function

* 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.

* Fix bug in permalinkstore.js for handling map names with periods.
  • Loading branch information
mulfvik authored Jul 11, 2024
1 parent 7030ace commit aeec21d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/permalink/permalinkstore.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ permalinkStore.getState = function getState(viewer, isExtended) {
state.pin = getPin().getGeometry().getCoordinates().map(coord => Math.round(coord))
.join();
}
if (viewer.getMapName()) {
state.map = viewer.getMapName().split('.')[0];
if (viewer.getMapName() && viewer.getMapName().indexOf('.') !== -1) {
const lastPointIndex = viewer.getMapName().lastIndexOf('.');
state.map = viewer.getMapName().substring(0, lastPointIndex);
}

Object.keys(additionalMapStateParams).forEach((key) => additionalMapStateParams[key](state));
Expand Down

0 comments on commit aeec21d

Please sign in to comment.