1- import { type LocationQuery , parseQuery , normalizeQuery } from '../query'
1+ import {
2+ type LocationQuery ,
3+ parseQuery ,
4+ normalizeQuery ,
5+ stringifyQuery ,
6+ } from '../query'
27import type { MatcherPattern } from './matcher-pattern'
38import { warn } from '../warning'
49import {
510 SLASH_RE ,
611 encodePath ,
712 encodeQueryValue as _encodeQueryValue ,
813} from '../encoding'
9- import { parseURL } from '../location'
14+ import { parseURL , stringifyURL } from '../location'
1015import type {
1116 MatcherLocationAsName ,
1217 MatcherLocationAsRelative ,
@@ -84,6 +89,7 @@ type TODO = any
8489
8590export interface NEW_MatcherLocationResolved {
8691 name : MatcherName
92+ fullPath : string
8793 path : string
8894 // TODO: generics?
8995 params : MatcherParamsFormatted
@@ -137,6 +143,7 @@ export function decode(
137143 }
138144 return '' + text
139145}
146+ // TODO: just add the null check to the original function in encoding.ts
140147
141148interface FnStableNull {
142149 ( value : null | undefined ) : null
@@ -191,7 +198,10 @@ export const NO_MATCH_LOCATION = {
191198 name : Symbol ( 'no-match' ) ,
192199 params : { } ,
193200 matched : [ ] ,
194- } satisfies Omit < NEW_MatcherLocationResolved , 'path' | 'hash' | 'query' >
201+ } satisfies Omit <
202+ NEW_MatcherLocationResolved ,
203+ 'path' | 'hash' | 'query' | 'fullPath'
204+ >
195205
196206export function createCompiledMatcher ( ) : NEW_Matcher_Resolve {
197207 const matchers = new Map < MatcherName , MatcherPattern > ( )
@@ -239,7 +249,6 @@ export function createCompiledMatcher(): NEW_Matcher_Resolve {
239249 }
240250 }
241251
242- // TODO: build fullPath
243252 return {
244253 ...url ,
245254 name : matcher . name ,
@@ -266,16 +275,20 @@ export function createCompiledMatcher(): NEW_Matcher_Resolve {
266275 transformObject ( String , encodeParam , mixedUnencodedParams [ 0 ] )
267276 )
268277
278+ // TODO: should pick query from the params but also from the location and merge them
279+ const query = {
280+ ...normalizeQuery ( location . query ) ,
281+ // ...matcher.extractQuery(mixedUnencodedParams[1])
282+ }
283+ const hash = mixedUnencodedParams [ 2 ] ?? location . hash ?? ''
284+
269285 return {
270286 name,
287+ fullPath : stringifyURL ( stringifyQuery , { path, query : { } , hash } ) ,
271288 path,
272289 params,
273- hash : mixedUnencodedParams [ 2 ] ?? location . hash ?? '' ,
274- // TODO: should pick query from the params but also from the location and merge them
275- query : {
276- ...normalizeQuery ( location . query ) ,
277- // ...matcher.extractQuery(mixedUnencodedParams[1])
278- } ,
290+ hash,
291+ query,
279292 matched : [ ] ,
280293 }
281294 }
0 commit comments