Skip to content
Snippets Groups Projects
Unverified Commit b6085d62 authored by karp's avatar karp
Browse files

Fix stacking query parameter

Multiple clicks on the login button added the next query parameter again.

Added logic to add the query parameter only once.
parent d1b57d5d
No related branches found
No related tags found
1 merge request!12Fix stacking query parameter
This commit is part of merge request !12. Comments created here will be created in the context of that merge request.
import { NavPageLink } from "./NavPageLink.mjs" import { NavPageLink } from "./NavPageLink.mjs"
import { logout, isLoggedIn } from "../../account.mjs" import { logout, isLoggedIn } from "../../account.mjs"
const hasQueryParam = (param, path) => (param in m.parsePathname(path).params);
export const Nav = { export const Nav = {
view() { view() {
return m("nav.box", [ return m("nav.box", [
...@@ -60,7 +63,7 @@ export const Nav = { ...@@ -60,7 +63,7 @@ export const Nav = {
iconOnly: true, iconOnly: true,
}) })
: m(NavPageLink, { : m(NavPageLink, {
href: `/login?next=${m.route.get() || "/"}`, href: hasQueryParam("next", m.route.get()) ? m.route.get() : `/login?next=${m.route.get() || "/"}`,
label: " Anmelden", label: " Anmelden",
icon: "fa-solid fa-right-to-bracket", icon: "fa-solid fa-right-to-bracket",
}), }),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment