@@ -55,13 +55,13 @@ describe('StaticResolver', () => {
5555 } )
5656
5757 describe ( 'resolve()' , ( ) => {
58- describe . todo ( 'absolute locations as strings' , ( ) => {
58+ describe ( 'absolute locations as strings' , ( ) => {
5959 it ( 'resolves string locations with no params' , ( ) => {
6060 const resolver = createStaticResolver ( [
6161 { name : 'root' , path : EMPTY_PATH_PATTERN_MATCHER } ,
6262 ] )
6363
64- expect ( resolver . resolve ( { path : '/?a=a&b=b#h' } ) ) . toMatchObject ( {
64+ expect ( resolver . resolve ( '/?a=a&b=b#h' ) ) . toMatchObject ( {
6565 path : '/' ,
6666 params : { } ,
6767 query : { a : 'a' , b : 'b' } ,
@@ -71,7 +71,7 @@ describe('StaticResolver', () => {
7171
7272 it ( 'resolves a not found string' , ( ) => {
7373 const resolver = createStaticResolver ( [ ] )
74- expect ( resolver . resolve ( { path : '/bar?q=1#hash' } ) ) . toEqual ( {
74+ expect ( resolver . resolve ( '/bar?q=1#hash' ) ) . toEqual ( {
7575 ...NO_MATCH_LOCATION ,
7676 fullPath : '/bar?q=1#hash' ,
7777 path : '/bar' ,
@@ -86,20 +86,18 @@ describe('StaticResolver', () => {
8686 { name : 'user-detail' , path : USER_ID_PATH_PATTERN_MATCHER } ,
8787 ] )
8888
89- expect ( resolver . resolve ( { path : '/users/1?a=a&b=b#h' } ) ) . toMatchObject ( {
89+ expect ( resolver . resolve ( '/users/1?a=a&b=b#h' ) ) . toMatchObject ( {
9090 path : '/users/1' ,
9191 params : { id : 1 } ,
9292 query : { a : 'a' , b : 'b' } ,
9393 hash : '#h' ,
9494 } )
95- expect ( resolver . resolve ( { path : '/users/54?a=a&b=b#h' } ) ) . toMatchObject (
96- {
97- path : '/users/54' ,
98- params : { id : 54 } ,
99- query : { a : 'a' , b : 'b' } ,
100- hash : '#h' ,
101- }
102- )
95+ expect ( resolver . resolve ( '/users/54?a=a&b=b#h' ) ) . toMatchObject ( {
96+ path : '/users/54' ,
97+ params : { id : 54 } ,
98+ query : { a : 'a' , b : 'b' } ,
99+ hash : '#h' ,
100+ } )
103101 } )
104102
105103 it ( 'resolve string locations with query' , ( ) => {
@@ -111,17 +109,15 @@ describe('StaticResolver', () => {
111109 } ,
112110 ] )
113111
114- expect ( resolver . resolve ( { path : '/foo?page=100&b=b#h' } ) ) . toMatchObject (
115- {
116- params : { page : 100 } ,
117- path : '/foo' ,
118- query : {
119- page : '100' ,
120- b : 'b' ,
121- } ,
122- hash : '#h' ,
123- }
124- )
112+ expect ( resolver . resolve ( '/foo?page=100&b=b#h' ) ) . toMatchObject ( {
113+ params : { page : 100 } ,
114+ path : '/foo' ,
115+ query : {
116+ page : '100' ,
117+ b : 'b' ,
118+ } ,
119+ hash : '#h' ,
120+ } )
125121 } )
126122
127123 it ( 'resolves string locations with hash' , ( ) => {
@@ -133,7 +129,7 @@ describe('StaticResolver', () => {
133129 } ,
134130 ] )
135131
136- expect ( resolver . resolve ( { path : '/foo?a=a&b=b#bar' } ) ) . toMatchObject ( {
132+ expect ( resolver . resolve ( '/foo?a=a&b=b#bar' ) ) . toMatchObject ( {
137133 hash : '#bar' ,
138134 params : { hash : 'bar' } ,
139135 path : '/foo' ,
@@ -151,9 +147,7 @@ describe('StaticResolver', () => {
151147 } ,
152148 ] )
153149
154- expect (
155- resolver . resolve ( { path : '/users/24?page=100#bar' } )
156- ) . toMatchObject ( {
150+ expect ( resolver . resolve ( '/users/24?page=100#bar' ) ) . toMatchObject ( {
157151 params : { id : 24 , page : 100 , hash : 'bar' } ,
158152 } )
159153 } )
@@ -258,6 +252,19 @@ describe('StaticResolver', () => {
258252 hash : '' ,
259253 } )
260254 } )
255+
256+ it ( 'treats object path as pathname only (no query/hash parsing)' , ( ) => {
257+ const resolver = createStaticResolver ( [
258+ { name : 'any-path' , path : ANY_PATH_PATTERN_MATCHER } ,
259+ ] )
260+ // Object with path containing query/hash should treat entire string as pathname
261+ expect ( resolver . resolve ( { path : '/?a=a&b=b#h' } ) ) . toMatchObject ( {
262+ path : '/?a=a&b=b#h' , // Full string treated as path
263+ query : { } , // Empty query
264+ hash : '' , // Empty hash
265+ params : { pathMatch : '/?a=a&b=b#h' } , // Matcher sees full string
266+ } )
267+ } )
261268 } )
262269
263270 describe ( 'named locations' , ( ) => {
0 commit comments