@@ -222,7 +222,11 @@ export function getRouteMatches(branches: Branch[], location: string): RouteMatc
222
222
return [ ] ;
223
223
}
224
224
225
- export function createLocation ( path : Accessor < string > , state : Accessor < any > ) : Location {
225
+ function createLocation (
226
+ path : Accessor < string > ,
227
+ state : Accessor < any > ,
228
+ queryWrapper ?: ( getQuery : ( ) => Params ) => Params
229
+ ) : Location {
226
230
const origin = new URL ( mockBase ) ;
227
231
const url = createMemo < URL > (
228
232
prev => {
@@ -244,6 +248,7 @@ export function createLocation(path: Accessor<string>, state: Accessor<any>): Lo
244
248
const search = createMemo ( ( ) => url ( ) . search , true ) ;
245
249
const hash = createMemo ( ( ) => url ( ) . hash ) ;
246
250
const key = ( ) => "" ;
251
+ const queryFn = on ( search , ( ) => extractSearchParams ( url ( ) ) ) as ( ) => Params ;
247
252
248
253
return {
249
254
get pathname ( ) {
@@ -261,7 +266,7 @@ export function createLocation(path: Accessor<string>, state: Accessor<any>): Lo
261
266
get key ( ) {
262
267
return key ( ) ;
263
268
} ,
264
- query : createMemoObject ( on ( search , ( ) => extractSearchParams ( url ( ) ) ) as ( ) => Params )
269
+ query : queryWrapper ? queryWrapper ( queryFn ) : createMemoObject ( queryFn )
265
270
} ;
266
271
}
267
272
@@ -281,7 +286,11 @@ export function createRouterContext(
281
286
integration : RouterIntegration ,
282
287
branches : ( ) => Branch [ ] ,
283
288
getContext ?: ( ) => any ,
284
- options : { base ?: string ; singleFlight ?: boolean ; transformUrl ?: ( url : string ) => string } = { }
289
+ options : {
290
+ base ?: string ;
291
+ singleFlight ?: boolean ;
292
+ transformUrl ?: ( url : string ) => string ;
293
+ } = { }
285
294
) : RouterContext {
286
295
const {
287
296
signal : [ source , setSource ] ,
@@ -335,7 +344,7 @@ export function createRouterContext(
335
344
} ;
336
345
const [ reference , setReference ] = createSignal ( source ( ) . value ) ;
337
346
const [ state , setState ] = createSignal ( source ( ) . state ) ;
338
- const location = createLocation ( reference , state ) ;
347
+ const location = createLocation ( reference , state , utils . queryWrapper ) ;
339
348
const referrers : LocationChange [ ] = [ ] ;
340
349
const submissions = createSignal < Submission < any , any > [ ] > ( isServer ? initFromFlash ( ) : [ ] ) ;
341
350
@@ -347,14 +356,18 @@ export function createRouterContext(
347
356
return getRouteMatches ( branches ( ) , location . pathname ) ;
348
357
} ) ;
349
358
350
- const params = createMemoObject ( ( ) => {
359
+ const buildParams = ( ) => {
351
360
const m = matches ( ) ;
352
361
const params : Params = { } ;
353
362
for ( let i = 0 ; i < m . length ; i ++ ) {
354
363
Object . assign ( params , m [ i ] . params ) ;
355
364
}
356
365
return params ;
357
- } ) ;
366
+ } ;
367
+
368
+ const params = utils . paramsWrapper
369
+ ? utils . paramsWrapper ( buildParams , branches )
370
+ : createMemoObject ( buildParams ) ;
358
371
359
372
const baseRoute : RouteContext = {
360
373
pattern : basePath ,
0 commit comments