Skip to content

Commit 4cea036

Browse files
HarshithaKPdougwilson
authored andcommitted
Add path-to-regexp@2.0.0-beta.1 changes to express 5 migration guide
closes #1114
1 parent 2fc9055 commit 4cea036

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

en/guide/migrating-5.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ See the [pull request](https://github.com/expressjs/express/pull/2237) for a lis
4444
**Changed**
4545

4646
<ul class="doclist">
47+
<li><a href="#path-syntax">Path route matching syntax</a></li>
4748
<li><a href="#app.router">app.router</a></li>
4849
<li><a href="#req.host">req.host</a></li>
4950
<li><a href="#req.query">req.query</a></li>
@@ -112,6 +113,20 @@ The `res.sendfile()` function has been replaced by a camel-cased version `res.se
112113

113114
<h3>Changed</h3>
114115

116+
<h4 id="path-syntax">Path route matching syntax</h4>
117+
118+
Path route matching syntax is when a string is supplied as the first parameter to the `app.all()`, `app.use()`, `app.METHOD()`, `router.all()`, `router.METHOD()`, and `router.use()` APIs. The following changes have been made to how the path string is matched to an incoming request:
119+
120+
- Add new `?`, `*`, and `+` parameter modifiers.
121+
- Matching group expressions are only RegExp syntax.
122+
* `(*)` is no longer valid and must be written as `(.*)`, for example.
123+
- Named matching groups no longer available by position in `req.params`.
124+
* `/:foo(.*)` only captures as `req.params.foo` and not available as `req.params[0]`.
125+
- Regular expressions can only be used in a matching group.
126+
* `/\\d+` is no longer valid and must be written as `/(\\d+)`.
127+
- Special `*` path segment behavior removed.
128+
* `/foo/*/bar` will match a literal `*` as the middle segment.
129+
115130
<h4 id="app.router">app.router</h4>
116131

117132
The `app.router` object, which was removed in Express 4, has made a comeback in Express 5. In the new version, this object is a just a reference to the base Express router, unlike in Express 3, where an app had to explicitly load it.

0 commit comments

Comments
 (0)