You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: en/guide/migrating-5.md
+8-9Lines changed: 8 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -129,15 +129,14 @@ The `res.sendfile()` function has been replaced by a camel-cased version `res.se
129
129
130
130
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:
131
131
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\\}`.
141
140
142
141
<h4id="rejected-promises">Rejected promises handled from middleware and handlers</h4>
0 commit comments