File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,9 @@ export default class Router extends String {
150150 const isSubset = ( subset , full ) => {
151151 return Object . entries ( subset ) . every ( ( [ key , value ] ) => {
152152 if ( Array . isArray ( value ) && Array . isArray ( full [ key ] ) ) {
153- return value . every ( ( v ) => full [ key ] . includes ( v ) ) ;
153+ return value . every (
154+ ( v ) => full [ key ] . includes ( v ) || full [ key ] . includes ( decodeURIComponent ( v ) ) ,
155+ ) ;
154156 }
155157
156158 if (
@@ -162,7 +164,7 @@ export default class Router extends String {
162164 return isSubset ( value , full [ key ] ) ;
163165 }
164166
165- return full [ key ] == value ;
167+ return full [ key ] == value || full [ key ] == decodeURIComponent ( value ) ;
166168 } ) ;
167169 } ;
168170
Original file line number Diff line number Diff line change @@ -1504,13 +1504,22 @@ describe('current()', () => {
15041504 } ) ;
15051505
15061506 // https://github.com/tighten/ziggy/issues/844
1507- test ( 'url containing hash' , ( ) => {
1507+ test ( 'url containing encoded hash' , ( ) => {
15081508 global . window . location . pathname = '/slashes/foo/Arcbees_c%23_doc.md' ;
15091509
15101510 expect ( route ( ) . current ( ) ) . toBe ( 'slashes' ) ;
15111511 expect ( route ( ) . current ( 'slashes' , { slug : 'Arcbees_c#_doc.md' } ) ) . toBe ( true ) ;
15121512 expect ( route ( ) . current ( 'slashes' , { slug : 'Arcbees_c%23_doc.md' } ) ) . toBe ( true ) ;
15131513 } ) ;
1514+
1515+ test ( 'url containing raw hash' , ( ) => {
1516+ // This specific case doesn't really matter because it's not valid, # is a URL anchor and can't be in the path like this
1517+ global . window . location . pathname = '/slashes/foo/Arcbees_c#_doc.md' ;
1518+
1519+ expect ( route ( ) . current ( ) ) . toBe ( 'slashes' ) ;
1520+ expect ( route ( ) . current ( 'slashes' , { slug : 'Arcbees_c#_doc.md' } ) ) . toBe ( true ) ;
1521+ expect ( route ( ) . current ( 'slashes' , { slug : 'Arcbees_c%23_doc.md' } ) ) . toBe ( true ) ;
1522+ } ) ;
15141523} ) ;
15151524
15161525describe ( 'json' , ( ) => {
You can’t perform that action at this time.
0 commit comments