File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -568,6 +568,7 @@ class Router {
568
568
*/
569
569
570
570
_stringifyPath ( path ) {
571
+ let fullPath = ''
571
572
if ( path && typeof path === 'object' ) {
572
573
if ( path . name ) {
573
574
const extend = Vue . util . extend
@@ -581,9 +582,9 @@ class Router {
581
582
if ( path . query ) {
582
583
params . queryParams = path . query
583
584
}
584
- return this . _recognizer . generate ( path . name , params )
585
+ fullPath = this . _recognizer . generate ( path . name , params )
585
586
} else if ( path . path ) {
586
- let fullPath = path . path
587
+ fullPath = path . path
587
588
if ( path . query ) {
588
589
const query = this . _recognizer . generateQueryString ( path . query )
589
590
if ( fullPath . indexOf ( '?' ) > - 1 ) {
@@ -592,13 +593,11 @@ class Router {
592
593
fullPath += query
593
594
}
594
595
}
595
- return fullPath
596
- } else {
597
- return ''
598
596
}
599
597
} else {
600
- return path ? path + '' : ''
598
+ fullPath = path ? path + '' : ''
601
599
}
600
+ return encodeURI ( fullPath )
602
601
}
603
602
}
604
603
Original file line number Diff line number Diff line change @@ -1147,4 +1147,16 @@ describe('Stringify Path', function () {
1147
1147
} ) . toThrow ( )
1148
1148
} )
1149
1149
1150
+ it ( 'encodeURI' , function ( ) {
1151
+ router . map ( {
1152
+ '/test/:id' : {
1153
+ name : 'a' ,
1154
+ component : { }
1155
+ }
1156
+ } )
1157
+ expect ( router . _stringifyPath ( '/hi/你好' ) ) . toBe ( encodeURI ( '/hi/你好' ) )
1158
+ expect ( router . _stringifyPath ( { path : '/hi/你好' } ) ) . toBe ( encodeURI ( '/hi/你好' ) )
1159
+ expect ( router . _stringifyPath ( { name : 'a' , params : { id : '你好' } } ) ) . toBe ( encodeURI ( '/test/你好' ) )
1160
+ } )
1161
+
1150
1162
} )
You can’t perform that action at this time.
0 commit comments