diff --git a/errors/invalid-route-source.md b/errors/invalid-route-source.md index c29c8610cf65c..0995c5714b5d1 100644 --- a/errors/invalid-route-source.md +++ b/errors/invalid-route-source.md @@ -2,12 +2,18 @@ #### Why This Error Occurred -When defining custom routes a route was added that causes an error during parsing. This can be due to trying to use normal `RegExp` syntax like negative lookaheads (`?!exclude`) without following `path-to-regexp`'s syntax for it. +When defining custom routes, or a middleware `matcher`, a pattern could not be parsed. + +This could have been due to trying to use normal `RegExp` syntax like negative lookaheads (`?!exclude`) without following [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp)'s syntax for it. #### Possible Ways to Fix It Wrap the `RegExp` part of your `source` as an un-named parameter. +--- + +Custom routes: + **Before** ```js @@ -26,6 +32,26 @@ Wrap the `RegExp` part of your `source` as an un-named parameter. } ``` +--- + +Middleware: + +**Before** + +```js +const config = { + matcher: '/feedback/(?!general)', +} +``` + +**After** + +```js +const config = { + matcher: '/feedback/((?!general).*)', +} +``` + ### Useful Links - [path-to-regexp](https://github.com/pillarjs/path-to-regexp)