Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure the query is cleared after startup #873

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/gm3/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,26 @@ class Application {
autoGo: true,
defaultValues: urlValues,
});

// parse the url
const url = new URL(document.location.href);

// check for mapbook parameter
const params = new URLSearchParams(document.location.search);
// preserve any of the parameters from the list
const safeParams = {};
const safeList = ["mapbook"];
safeList.forEach((paramName) => {
if (params[paramName]) {
safeParams[paramName] = params[paramName];
}
});

const nextParams = new URLSearchParams(safeParams);
url.search = nextParams.toString();

// clear the query from the URL
window.history.pushState({}, document.title, url.toString());
} else {
console.error("Failed to load service specified in ?service=");
}
Expand Down
Loading