|
@@ -0,0 +1,19 @@
|
|
|
|
|
+/**
|
|
|
|
|
+ * This middleware preserve some global query parameters during the navigation,
|
|
|
|
|
+ * like the theme color or the parent organization
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+const PRESERVE = ['parent', 'theme', 'view']
|
|
|
|
|
+
|
|
|
|
|
+export default function ({ from, route, redirect }) {
|
|
|
|
|
+ let redirected = false
|
|
|
|
|
+ for (const param in from.query) {
|
|
|
|
|
+ if (PRESERVE.includes(param) && !(param in route.query)) {
|
|
|
|
|
+ route.query[param] = from.query[param]
|
|
|
|
|
+ redirected = true
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (redirected) {
|
|
|
|
|
+ redirect(route)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|