File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -4,19 +4,25 @@ const form = document.querySelector(".formkit-sticky-bar")
4
4
const fromNewsletter = queryParams.get("fromNewsletter")
5
5
6
6
if (fromNewsletter === "true") {
7
+ queryParams.delete("fromNewsletter")
8
+ const stringifiedParams = queryParams.toString()
7
9
history.replaceState(
8
10
null,
9
11
null,
10
- `${location.pathname}?${queryParams.toString()}${location.hash}`
12
+ `${location.pathname}${stringifiedParams ? `?${queryParams.toString()}` : ""
13
+ }${location.hash}`
11
14
)
12
15
localStorage.setItem("subscribed-to-newsletter", true)
13
16
}
14
17
15
18
if (fromNewsletter === "false") {
19
+ queryParams.delete("fromNewsletter")
20
+ const stringifiedParams = queryParams.toString()
16
21
history.replaceState(
17
22
null,
18
23
null,
19
- `${location.pathname}?${queryParams.toString()}${location.hash}`
24
+ `${location.pathname}${stringifiedParams ? `?${queryParams.toString()}` : ""
25
+ }${location.hash}`
20
26
)
21
27
localStorage.removeItem("subscribed-to-newsletter")
22
28
localStorage.removeItem("date-of-last-newsletter-link")
@@ -87,5 +93,5 @@ document.addEventListener("click", e => {
87
93
if (e.target.matches("[data-formkit-close]")) {
88
94
sessionStorage.setItem("form-closed", true)
89
95
}
90
- })
96
+ })
91
97
</script >
Original file line number Diff line number Diff line change @@ -19,10 +19,12 @@ plausible("pageview", {
19
19
})
20
20
21
21
if (shouldClean) {
22
+ const stringifiedParams = queryParams.toString()
22
23
history.replaceState(
23
24
null,
24
25
null,
25
- `${location.pathname}?${queryParams}${location.hash}`
26
+ `${location.pathname}${stringifiedParams ? `?${queryParams.toString()}` : ""
27
+ }${location.hash}`
26
28
)
27
29
}
28
30
},
You can’t perform that action at this time.
0 commit comments