@@ -333,6 +333,26 @@ describe('encoding: URL param segment for /posts/$slug', () => {
333333 expect ( router . state . location . pathname ) . toBe ( '/posts/🚀' )
334334 } )
335335
336+ it ( 'state.location.pathname, should have the params.slug value of "100%25"' , async ( ) => {
337+ const { router } = createTestRouter ( {
338+ history : createMemoryHistory ( { initialEntries : [ '/posts/100%25' ] } ) ,
339+ } )
340+
341+ await act ( ( ) => router . load ( ) )
342+
343+ expect ( router . state . location . pathname ) . toBe ( '/posts/100%25' )
344+ } )
345+
346+ it ( 'state.location.pathname, should have the params.slug value of "100%26"' , async ( ) => {
347+ const { router } = createTestRouter ( {
348+ history : createMemoryHistory ( { initialEntries : [ '/posts/100%26' ] } ) ,
349+ } )
350+
351+ await act ( ( ) => router . load ( ) )
352+
353+ expect ( router . state . location . pathname ) . toBe ( '/posts/100%26' )
354+ } )
355+
336356 it ( 'state.location.pathname, should have the params.slug value of "%F0%9F%9A%80"' , async ( ) => {
337357 const { router } = createTestRouter ( {
338358 history : createMemoryHistory ( { initialEntries : [ '/posts/%F0%9F%9A%80' ] } ) ,
@@ -413,6 +433,78 @@ describe('encoding: URL param segment for /posts/$slug', () => {
413433 expect ( ( match . params as unknown as any ) . slug ) . toBe ( '🚀' )
414434 } )
415435
436+ it ( 'params.slug for the matched route, should be "100%"' , async ( ) => {
437+ const { router, routes } = createTestRouter ( {
438+ history : createMemoryHistory ( { initialEntries : [ '/posts/100%25' ] } ) ,
439+ } )
440+
441+ await act ( ( ) => router . load ( ) )
442+
443+ const match = router . state . matches . find (
444+ ( r ) => r . routeId === routes . postIdRoute . id ,
445+ )
446+
447+ if ( ! match ) {
448+ throw new Error ( 'No match found' )
449+ }
450+
451+ expect ( ( match . params as unknown as any ) . slug ) . toBe ( '100%' )
452+ } )
453+
454+ it ( 'params.slug for the matched route, should be "100&"' , async ( ) => {
455+ const { router, routes } = createTestRouter ( {
456+ history : createMemoryHistory ( { initialEntries : [ '/posts/100%26' ] } ) ,
457+ } )
458+
459+ await act ( ( ) => router . load ( ) )
460+
461+ const match = router . state . matches . find (
462+ ( r ) => r . routeId === routes . postIdRoute . id ,
463+ )
464+
465+ if ( ! match ) {
466+ throw new Error ( 'No match found' )
467+ }
468+
469+ expect ( ( match . params as unknown as any ) . slug ) . toBe ( '100&' )
470+ } )
471+
472+ it ( 'params.slug for the matched route, should be "100%100"' , async ( ) => {
473+ const { router, routes } = createTestRouter ( {
474+ history : createMemoryHistory ( { initialEntries : [ '/posts/100%25100' ] } ) ,
475+ } )
476+
477+ await act ( ( ) => router . load ( ) )
478+
479+ const match = router . state . matches . find (
480+ ( r ) => r . routeId === routes . postIdRoute . id ,
481+ )
482+
483+ if ( ! match ) {
484+ throw new Error ( 'No match found' )
485+ }
486+
487+ expect ( ( match . params as unknown as any ) . slug ) . toBe ( '100%100' )
488+ } )
489+
490+ it ( 'params.slug for the matched route, should be "100&100"' , async ( ) => {
491+ const { router, routes } = createTestRouter ( {
492+ history : createMemoryHistory ( { initialEntries : [ '/posts/100%26100' ] } ) ,
493+ } )
494+
495+ await act ( ( ) => router . load ( ) )
496+
497+ const match = router . state . matches . find (
498+ ( r ) => r . routeId === routes . postIdRoute . id ,
499+ )
500+
501+ if ( ! match ) {
502+ throw new Error ( 'No match found' )
503+ }
504+
505+ expect ( ( match . params as unknown as any ) . slug ) . toBe ( '100&100' )
506+ } )
507+
416508 it ( 'params.slug for the matched route, should be "framework/react/guide/file-based-routing tanstack" instead of it being "framework%2Freact%2Fguide%2Ffile-based-routing%20tanstack"' , async ( ) => {
417509 const { router, routes } = createTestRouter ( {
418510 history : createMemoryHistory ( {
@@ -490,6 +582,26 @@ describe('encoding: URL splat segment for /$', () => {
490582 expect ( router . state . location . pathname ) . toBe ( '/🚀' )
491583 } )
492584
585+ it ( 'state.location.pathname, should have the params._splat value of "100%25"' , async ( ) => {
586+ const { router } = createTestRouter ( {
587+ history : createMemoryHistory ( { initialEntries : [ '/100%25' ] } ) ,
588+ } )
589+
590+ await router . load ( )
591+
592+ expect ( router . state . location . pathname ) . toBe ( '/100%25' )
593+ } )
594+
595+ it ( 'state.location.pathname, should have the params._splat value of "100%26"' , async ( ) => {
596+ const { router } = createTestRouter ( {
597+ history : createMemoryHistory ( { initialEntries : [ '/100%26' ] } ) ,
598+ } )
599+
600+ await router . load ( )
601+
602+ expect ( router . state . location . pathname ) . toBe ( '/100%26' )
603+ } )
604+
493605 it ( 'state.location.pathname, should have the params._splat value of "%F0%9F%9A%80"' , async ( ) => {
494606 const { router } = createTestRouter ( {
495607 history : createMemoryHistory ( { initialEntries : [ '/%F0%9F%9A%80' ] } ) ,
@@ -619,6 +731,21 @@ describe('encoding: URL path segment', () => {
619731 output : '/path-segment/é' ,
620732 type : 'not encoded' ,
621733 } ,
734+ {
735+ input : '/path-segment/100%25' , // `%25` = `%`
736+ output : '/path-segment/100%25' ,
737+ type : 'not encoded' ,
738+ } ,
739+ {
740+ input : '/path-segment/100%25%25' ,
741+ output : '/path-segment/100%25%25' ,
742+ type : 'not encoded' ,
743+ } ,
744+ {
745+ input : '/path-segment/100%26' , // `%26` = `&`
746+ output : '/path-segment/100%26' ,
747+ type : 'not encoded' ,
748+ } ,
622749 {
623750 input : '/path-segment/%F0%9F%9A%80' ,
624751 output : '/path-segment/🚀' ,
@@ -629,6 +756,22 @@ describe('encoding: URL path segment', () => {
629756 output : '/path-segment/🚀to%2Fthe%2Fmoon' ,
630757 type : 'encoded' ,
631758 } ,
759+ {
760+ input : '/path-segment/%25%F0%9F%9A%80to%2Fthe%2Fmoon' ,
761+ output : '/path-segment/%25🚀to%2Fthe%2Fmoon' ,
762+ type : 'encoded' ,
763+ } ,
764+ {
765+ input : '/path-segment/%F0%9F%9A%80to%2Fthe%2Fmoon%25' ,
766+ output : '/path-segment/🚀to%2Fthe%2Fmoon%25' ,
767+ type : 'encoded' ,
768+ } ,
769+ {
770+ input :
771+ '/path-segment/%F0%9F%9A%80to%2Fthe%2Fmoon%25%F0%9F%9A%80to%2Fthe%2Fmoon' ,
772+ output : '/path-segment/🚀to%2Fthe%2Fmoon%25🚀to%2Fthe%2Fmoon' ,
773+ type : 'encoded' ,
774+ } ,
632775 {
633776 input : '/path-segment/🚀' ,
634777 output : '/path-segment/🚀' ,
0 commit comments