mirror of
https://github.com/expressjs/expressjs.com.git
synced 2026-02-21 19:41:33 +00:00
i18n: new crowdin translations (#2138)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
This commit is contained in:
committed by
GitHub
parent
7fb7fe1a28
commit
c6478c2c0b
@@ -81,6 +81,7 @@ You can find the list of available codemods [here](https://github.com/expressjs/
|
||||
<li><a href="#app.router">app.router</a></li>
|
||||
<li><a href="#req.body">req.body</a></li>
|
||||
<li><a href="#req.host">req.host</a></li>
|
||||
<li><a href="#req.params">req.params</a></li>
|
||||
<li><a href="#req.query">req.query</a></li>
|
||||
<li><a href="#res.clearCookie">res.clearCookie</a></li>
|
||||
<li><a href="#res.status">res.status</a></li>
|
||||
@@ -559,7 +560,7 @@ Express 4, está de volta no Express 5. Na nove versão, este objeto é
|
||||
apenas uma referência para o roteador Express base, diferentemente do
|
||||
Express 3, onde um aplicativo tinha que carregá-lo explicitamente.
|
||||
|
||||
<h3 id="req.body">req.body</h3>
|
||||
<h3 id="req.body">req.body</h3>
|
||||
|
||||
The `req.body` property returns `undefined` when the body has not been parsed. In Express 4, it returns `{}` by default.
|
||||
|
||||
@@ -569,6 +570,49 @@ No Express 4, a função `req.host`
|
||||
incorretamente removia o número da porta caso estivesse presente. No
|
||||
Express 5 o número da porta é mantido.
|
||||
|
||||
<h3 id="req.params">req.params</h3>
|
||||
|
||||
The `req.params` object now has a **null prototype** when using string paths. However, if the path is defined with a regular expression, `req.params` remains a standard object with a normal prototype. Additionally, there are two important behavioral changes:
|
||||
|
||||
**Wildcard parameters are now arrays:**
|
||||
|
||||
Wildcards (e.g., `/*splat`) capture path segments as an array instead of a single string.
|
||||
|
||||
```js
|
||||
app.get('/*splat', (req, res) => {
|
||||
// GET /foo/bar
|
||||
console.dir(req.params)
|
||||
// => [Object: null prototype] { splat: [ 'foo', 'bar' ] }
|
||||
})
|
||||
```
|
||||
|
||||
**Unmatched parameters are omitted:**
|
||||
|
||||
In Express 4, unmatched wildcards were empty strings (`''`) and optional `:` parameters (using `?`) had a key with value `undefined`. In Express 5, unmatched parameters are completely omitted from `req.params`.
|
||||
|
||||
```js
|
||||
// v4: unmatched wildcard is empty string
|
||||
app.get('/*', (req, res) => {
|
||||
// GET /
|
||||
console.dir(req.params)
|
||||
// => { '0': '' }
|
||||
})
|
||||
|
||||
// v4: unmatched optional param is undefined
|
||||
app.get('/:file.:ext?', (req, res) => {
|
||||
// GET /image
|
||||
console.dir(req.params)
|
||||
// => { file: 'image', ext: undefined }
|
||||
})
|
||||
|
||||
// v5: unmatched optional param is omitted
|
||||
app.get('/:file{.:ext}', (req, res) => {
|
||||
// GET /image
|
||||
console.dir(req.params)
|
||||
// => [Object: null prototype] { file: 'image' }
|
||||
})
|
||||
```
|
||||
|
||||
<h3 id="req.query">req.query</h3>
|
||||
|
||||
The `req.query` property is no longer a writable property and is instead a getter. The default query parser has been changed from "extended" to "simple".
|
||||
|
||||
Reference in New Issue
Block a user