File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
Expand file tree Collapse file tree 2 files changed +23
-2
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 @@ -1502,6 +1502,25 @@ describe('current()', () => {
15021502
15031503 global . window = oldWindow ;
15041504 } ) ;
1505+
1506+ // https://github.com/tighten/ziggy/issues/844
1507+ test ( 'url containing encoded hash' , ( ) => {
1508+ global . window . location . pathname = '/slashes/foo/Arcbees_c%23_doc.md' ;
1509+
1510+ expect ( route ( ) . current ( ) ) . toBe ( 'slashes' ) ;
1511+ expect ( route ( ) . current ( 'slashes' , { slug : 'Arcbees_c#_doc.md' } ) ) . toBe ( true ) ;
1512+ expect ( route ( ) . current ( 'slashes' , { slug : 'Arcbees_c%23_doc.md' } ) ) . toBe ( true ) ;
1513+ } ) ;
1514+
1515+ test ( 'url containing raw hash' , ( ) => {
1516+ // This specific case may not matter because it's not valid, # is a URL anchor and
1517+ // can't be in the path like this, but in general this should work both ways
1518+ global . window . location . pathname = '/slashes/foo/Arcbees_c#_doc.md' ;
1519+
1520+ expect ( route ( ) . current ( ) ) . toBe ( 'slashes' ) ;
1521+ expect ( route ( ) . current ( 'slashes' , { slug : 'Arcbees_c#_doc.md' } ) ) . toBe ( true ) ;
1522+ expect ( route ( ) . current ( 'slashes' , { slug : 'Arcbees_c%23_doc.md' } ) ) . toBe ( true ) ;
1523+ } ) ;
15051524} ) ;
15061525
15071526describe ( 'json' , ( ) => {
You can’t perform that action at this time.
0 commit comments