File tree Expand file tree Collapse file tree 2 files changed +3
-5
lines changed Expand file tree Collapse file tree 2 files changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ Here's a basic example demonstrating simple routes:
94
94
<button on:click={navigateWithQuery}>Search</button>
95
95
```
96
96
97
- ### get query strings
97
+ ### get then remove query strings
98
98
``` svelte
99
99
<!-- SomeComponent.svelte -->
100
100
<script>
@@ -107,6 +107,7 @@ Here's a basic example demonstrating simple routes:
107
107
// Check if the "foo" query parameter exists (i.e /myroute?foo=bar) and log it
108
108
if (router.hasQueryParam('foo')) {
109
109
console.log("Value of foo:", router.getQueryParam('foo'));
110
+ router.removeQueryParams(["foo"]);
110
111
}
111
112
112
113
// Get a specific query parameter
Original file line number Diff line number Diff line change 5
5
6
6
const parentRouterContext = getContext (' router' ); // Might be undefined if this is the root router
7
7
8
- // --- BEGIN MODIFIED SECTION FOR EARLY QUERY PARSING ---
9
8
let initialQuery = {};
10
9
let initialFullPath = ' /' ;
11
10
19
18
initialQuery = _parseQuery (' ?' + parts[1 ]);
20
19
}
21
20
}
22
- // --- END MODIFIED SECTION FOR EARLY QUERY PARSING ---
23
21
24
22
let initialBase = ' /' ;
25
23
let initialRelativePath = initialFullPath;
150
148
// If url prop was used, initialQuery has it. Otherwise, it's {}.
151
149
}
152
150
}
153
-
151
+
154
152
function removeQueryParams (keysToRemove ) {
155
153
if (typeof window !== ' undefined' ) {
156
154
const currentSearch = window .location .search ; // Get current query from actual URL
242
240
router .getQueryParam = (key ) => router .query [key];
243
241
router .hasQueryParam = (key ) => Object .prototype .hasOwnProperty .call (router .query , key);
244
242
router .removeQueryParams = removeQueryParams;
245
-
246
243
setContext (' router' , router);
247
244
</script >
248
245
You can’t perform that action at this time.
0 commit comments