mirror of
https://github.com/expressjs/expressjs.com.git
synced 2026-02-26 02:54:58 +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
@@ -1,6 +1,6 @@
|
||||
terms_of_use: Terms of Use
|
||||
privacy_policy: Privacy Policy
|
||||
coc: Code of Conduct
|
||||
trademark_policy: Trademark Policy
|
||||
security_policy: Security Policy
|
||||
license: License
|
||||
terms_of_use: Conditions d’utilisation
|
||||
privacy_policy: Politique de Confidentialité
|
||||
coc: Code de Conduite
|
||||
trademark_policy: Politique de Marque
|
||||
security_policy: Politique de Sécurité
|
||||
license: Licence
|
||||
|
||||
@@ -72,6 +72,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>
|
||||
@@ -512,7 +513,7 @@ const server = app.listen(8080, '0.0.0.0', (error) => {
|
||||
|
||||
Das Objekt `app.router`, das in Express 4 entfernt wurde, ist in Express 5 wieder verfügbar. In der neuen Version fungiert dieses Objekt nur als Referenz zum Express-Basisrouter – im Gegensatz zu Express 3, wo die Anwendung dieses Objekt explizit laden musste.
|
||||
|
||||
<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.
|
||||
|
||||
@@ -520,6 +521,49 @@ The `req.body` property returns `undefined` when the body has not been parsed. I
|
||||
|
||||
In Express 4 übergab die Funktion `req.host` nicht ordnungsgemäß eine eventuell vorhandene Portnummer. In Express 5 wird die Portnummer beibehalten.
|
||||
|
||||
<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".
|
||||
|
||||
@@ -72,6 +72,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>
|
||||
@@ -512,7 +513,7 @@ const server = app.listen(8080, '0.0.0.0', (error) => {
|
||||
|
||||
El objeto `app.router`, que se ha eliminado en Express 4, ha vuelto en Express 5. En la nueva versión, este objeto es sólo una referencia al direccionador de Express base, a diferencia de en Express 3, donde una aplicación debía cargarlo explícitamente.
|
||||
|
||||
<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.
|
||||
|
||||
@@ -520,6 +521,49 @@ The `req.body` property returns `undefined` when the body has not been parsed. I
|
||||
|
||||
En Express 4, la función `req.host` fragmentaba incorrectamente el número de puerto si estaba presente. In Express 5, the port number is maintained.
|
||||
|
||||
<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".
|
||||
|
||||
@@ -81,6 +81,7 @@ nom pour app.param(name, fn)</a></li>
|
||||
<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>
|
||||
@@ -567,7 +568,7 @@ const server = app.listen(8080, '0.0.0.0', (error) => {
|
||||
L'objet `app.router`, qui a été supprimé dans Express 4, est revenu dans Express 5. Dans la version, cet objet
|
||||
n'est qu'une référence dans le routeur Express de base, contrairement à Express 3, où une application devait le charger explicitement.
|
||||
|
||||
<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.
|
||||
|
||||
@@ -576,6 +577,49 @@ The `req.body` property returns `undefined` when the body has not been parsed. I
|
||||
Dans Express 4, la `req.host` retirait de
|
||||
manière incorrecte le numéro de port s'il était présent. Dans Express 5, ce numéro de port est conservé.
|
||||
|
||||
<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".
|
||||
|
||||
@@ -13,7 +13,7 @@ _Routage_ fait référence à la définition de points finaux d'application (URI
|
||||
Pour une introduction au routage, voir [Basic routing](/{{ page.lang }}/starter/basic-routing.html).
|
||||
|
||||
Vous définissez le routage à l’aide des méthodes de l’objet app d’Express correspondant aux méthodes HTTP :
|
||||
par exemple, `app.get()` pour les requêtes GET et \`app.post pour les requêtes POST. Pour la liste complète,
|
||||
par exemple, `app.get()` pour les requêtes GET et `app.post` pour les requêtes POST. Pour la liste complète,
|
||||
voir [app.METHOD](/{{ page.lang }}/5x/api.html#app.METHOD). Vous pouvez également utiliser [app.all()](/{{ page.lang }}/5x/api.html#app.all) pour gérer toutes les méthodes HTTP et [app.use()](/{{ page.lang }}/5x/api.html#app.use) spécifier le middleware comme fonction de rappel (Voir [Utilisation du middleware](/{{ page.lang }}/guide/using-middleware.html) pour plus de détails).
|
||||
|
||||
Ces méthodes de routage spécifient une fonction de rappel (parfois "appelée fonction de gestion") qui est appelée lorsque l'application reçoit une requête correspondant à la route (point de terminaison) et à la méthode HTTP spécifiées. Autrement dit, l'application "écoute" les requêtes qui correspondent à la ou aux routes et à la ou aux méthodes spécifiées, et lorsqu'une correspondance est détectée, elle appelle la fonction de rappel définie.
|
||||
|
||||
@@ -72,6 +72,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>
|
||||
@@ -512,7 +513,7 @@ const server = app.listen(8080, '0.0.0.0', (error) => {
|
||||
|
||||
L'oggetto `app.router`, che era stato rimosso in Express 4, è ritornato in Express 5. Nella nuova versione, questo oggetto è solo un riferimento al router Express di base, diversamente da Express 3, in cui un'applicazione aveva il compito esplicito di caricarlo.
|
||||
|
||||
<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.
|
||||
|
||||
@@ -520,6 +521,49 @@ The `req.body` property returns `undefined` when the body has not been parsed. I
|
||||
|
||||
In Express 4, la funzione `req.host` andava a rimuovere in modo non corretto il numero porta nel caso fosse stato presente. In Express 5 il numero porta viene conservato.
|
||||
|
||||
<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".
|
||||
|
||||
@@ -72,6 +72,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>
|
||||
@@ -512,7 +513,7 @@ const server = app.listen(8080, '0.0.0.0', (error) => {
|
||||
|
||||
`app.router` オブジェクトは、Express 4 で削除されましたが、Express 5 で復帰しました。アプリケーションが明示的にロードする必要があった Express 3 とは異なり、新しいバージョンでは、このオブジェクトは基本の Express ルーターの単なる参照です。 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.
|
||||
|
||||
<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.
|
||||
|
||||
@@ -520,6 +521,49 @@ The `req.body` property returns `undefined` when the body has not been parsed. I
|
||||
|
||||
Express 4 では、`req.host` 関数は、ポート番号が存在する場合に、ポート番号を誤って削除していました。Express 5 では、ポート番号は維持されます。 In Express 5, the port number is maintained.
|
||||
|
||||
<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".
|
||||
|
||||
@@ -72,6 +72,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>
|
||||
@@ -512,7 +513,7 @@ const server = app.listen(8080, '0.0.0.0', (error) => {
|
||||
|
||||
Express 4에서 제거되었던 `app.router` 오브젝트가 Express 5에 되돌아왔습니다. Express 3에서는 앱이 이 오브젝트를 명시적으로 로드해야 했던 것과 달리, 새 버전에서 이 오브젝트는 단순히 기본 Express 라우터에 대한 참조의 역할을 합니다.
|
||||
|
||||
<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.
|
||||
|
||||
@@ -520,6 +521,49 @@ The `req.body` property returns `undefined` when the body has not been parsed. I
|
||||
|
||||
Express 4에서, 포트 번호가 존재하는 경우 `req.host` 함수는 포트 번호를 올바르지 않게 제거했습니다. Express 5에서는 포트 번호가 유지됩니다.
|
||||
|
||||
<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".
|
||||
|
||||
@@ -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".
|
||||
|
||||
@@ -72,6 +72,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>
|
||||
@@ -512,7 +513,7 @@ const server = app.listen(8080, '0.0.0.0', (error) => {
|
||||
|
||||
在 Express 4 中已移除的 `app.router` 对象在 Express 5 中已恢复。在新版本中,此对象只是对 Express 基本路由器的引用,不像在 Express 3 中应用程序必须显式将该路由器装入。 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.
|
||||
|
||||
<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.
|
||||
|
||||
@@ -520,6 +521,49 @@ The `req.body` property returns `undefined` when the body has not been parsed. I
|
||||
|
||||
在 Express 4 中,如果存在端口号,`req.host` 函数会错误地将其剥离。在 Express 5 中,则会保留端口号。 In Express 5, the port number is maintained.
|
||||
|
||||
<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".
|
||||
|
||||
@@ -72,6 +72,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>
|
||||
@@ -514,7 +515,7 @@ const server = app.listen(8080, '0.0.0.0', (error) => {
|
||||
`app.router` 物件已在 Express 4 中移除,在 Express 5 中又重新納入。
|
||||
在新版本中,這個物件只用來參照至基本 Express 路由器,不像在 Express 3 中,應用程式還得明確載入它。 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.
|
||||
|
||||
<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.
|
||||
|
||||
@@ -522,6 +523,49 @@ The `req.body` property returns `undefined` when the body has not been parsed. I
|
||||
|
||||
In Express 4, the `req.host` function incorrectly stripped off the port number if it was present. In Express 5, the port number is maintained.
|
||||
|
||||
<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