Skip to content

Commit

Permalink
Only preserve version query (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
karimi authored Jun 3, 2024
1 parent 81ebf85 commit ff1e85c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions quasar_site/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ export default route(function (/* { store, ssrContext } */) {
history: createHistory(process.env.VUE_ROUTER_BASE)
})

function hasQueryParams(route) {
return !!Object.keys(route.query).length;
function hasVersionParams(route) {
return Object.keys(route.query).includes("version");
}

Router.beforeEach((to, from, next) => {
if (!hasQueryParams(to) && hasQueryParams(from)) {
next({ path: to.path, query: from.query, hash: to.hash });
if (!hasVersionParams(to) && hasVersionParams(from)) {
next({
path: to.path,
query: { ...to.query, version: from.query["version"] },
hash: to.hash,
});
} else {
next();
}
Expand Down

0 comments on commit ff1e85c

Please sign in to comment.