File tree Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ export function compilePattern(pattern) {
71
71
* - ** Consumes (greedy) all characters up to the next character
72
72
* in the pattern, or to the end of the URL if there is none
73
73
*
74
+ * The function calls callback(error, matched) when finished.
74
75
* The return value is an object with the following properties:
75
76
*
76
77
* - remainingPathname
Original file line number Diff line number Diff line change @@ -276,6 +276,19 @@ describe('Router', function () {
276
276
} )
277
277
} )
278
278
279
+ it ( 'handles error that are not valid URI character' , function ( done ) {
280
+ const errorSpy = expect . createSpy ( )
281
+
282
+ render ( (
283
+ < Router history = { createHistory ( '/%' ) } onError = { errorSpy } >
284
+ < Route path = "*" />
285
+ </ Router >
286
+ ) , node , function ( ) {
287
+ expect ( errorSpy ) . toHaveBeenCalled ( )
288
+ done ( )
289
+ } )
290
+ } )
291
+
279
292
} )
280
293
281
294
describe ( 'render prop' , function ( ) {
Original file line number Diff line number Diff line change @@ -88,13 +88,17 @@ function matchRouteDeep(
88
88
// Only try to match the path if the route actually has a pattern, and if
89
89
// we're not just searching for potential nested absolute paths.
90
90
if ( remainingPathname !== null && pattern ) {
91
- const matched = matchPattern ( pattern , remainingPathname )
92
- if ( matched ) {
93
- remainingPathname = matched . remainingPathname
94
- paramNames = [ ...paramNames , ...matched . paramNames ]
95
- paramValues = [ ...paramValues , ...matched . paramValues ]
96
- } else {
97
- remainingPathname = null
91
+ try {
92
+ const matched = matchPattern ( pattern , remainingPathname )
93
+ if ( matched ) {
94
+ remainingPathname = matched . remainingPathname
95
+ paramNames = [ ...paramNames , ...matched . paramNames ]
96
+ paramValues = [ ...paramValues , ...matched . paramValues ]
97
+ } else {
98
+ remainingPathname = null
99
+ }
100
+ } catch ( error ) {
101
+ callback ( error )
98
102
}
99
103
100
104
// By assumption, pattern is non-empty here, which is the prerequisite for
You can’t perform that action at this time.
0 commit comments