Skip to content

Commit 7cdb0e5

Browse files
committed
bring changes from expressjs#1317
1 parent 2e9de0d commit 7cdb0e5

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

en/guide/migrating-5.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,14 @@ The `res.sendfile()` function has been replaced by a camel-cased version `res.se
129129

130130
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:
131131

132-
- Add new `?`, `*`, and `+` parameter modifiers.
133-
- Matching group expressions are only RegExp syntax.
134-
* `(*)` is no longer valid and must be written as `(.*)`, for example.
135-
- Named matching groups no longer available by position in `req.params`.
136-
* `/:foo(.*)` only captures as `req.params.foo` and not available as `req.params[0]`.
137-
- Regular expressions can only be used in a matching group.
138-
* `/\\d+` is no longer valid and must be written as `/(\\d+)`.
139-
- Special `*` path segment behavior removed.
140-
* `/foo/*/bar` will match a literal `*` as the middle segment.
132+
- Add new `?`, `*`, and `+` parameter modifiers. For example `/users/:user+` now matches `/users/1`, `/users/1/2`, etc. but not `/users`.
133+
- The special `*` path segment behavior has been removed. This means that `*` is no longer a valid path and `/foo/*/bar` now matches a literal `'*'`. For the previous behaviour, a `(.*)` matching group should be used instead.
134+
- Named matching groups no longer available by position in `req.params`. For example, `/:foo(.*)` only captures as `req.params.foo` and not available as `req.params[0]`.
135+
- Regular expressions can now only be used in a matching group. For example, `/users/\\d+` is invalid and should be written as `/users/(\\d+))`.
136+
- It is now possible to use named capturing groups in paths using `RegExp`, for example `/\/(?<group>.+)/` would result in `req.params.group` being populated.
137+
- Custom prefix and suffix groups are now supported using `{}`, for example `/:entity{-:action}?` would match `/user` and `/user-delete`.
138+
- Unbalanced patterns now produce an error. For example `/test(foo` previously worked, but now the opening parenthesis `(` must be escaped to match the previous behavior: `/test\\(foo`.
139+
- As with parentheses, curly brackets also require escaping. That is, `/user{:id}` no longer matches `/user{42}` as before unless written as `/user\\{:id\\}`.
141140

142141
<h4 id="rejected-promises">Rejected promises handled from middleware and handlers</h4>
143142

0 commit comments

Comments
 (0)