Skip to content

Commit 462ddb0

Browse files
committed
Update internal links and anchors in API docs
Internal links have been changed to relative URLs. This should help with redirecting to translated pages (the URL won't have to be localized) and keeping the right version. Anchors that point to headers that are localized will have to be changed.
1 parent 8ad1841 commit 462ddb0

12 files changed

Lines changed: 150 additions & 149 deletions

File tree

src/content/api/3x/api/request/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ where "proxy2" is the furthest down-stream.
164164
This property is much like `req.url`, however it retains
165165
the original request url, allowing you to rewrite `req.url`
166166
freely for internal routing purposes. For example the "mounting" feature
167-
of <a href="#app.use">app.use()</a> will rewrite `req.url` to
167+
of [app.use()](../application/#appusepath-function) will rewrite `req.url` to
168168
strip the mount point.
169169

170170
```js
@@ -243,7 +243,7 @@ console.dir(req.query.shoe.type);
243243

244244
### req.res
245245

246-
This property holds a reference to the <a href="#response">response object</a>
246+
This property holds a reference to the [response object](../response/)
247247
that relates to this request object.
248248

249249
### req.route

src/content/api/3x/api/response/index.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ res.send('<p>some html</p>');
2424

2525
Response local variables are scoped to the request, thus only
2626
available to the view(s) rendered during that request / response
27-
cycle, if any. Otherwise this API is identical to <a href="#app.locals">app.locals</a>.
27+
cycle, if any. Otherwise this API is identical to [app.locals](../application/#applocals).
2828

2929
This object is useful for exposing request-level information such as the
3030
request pathname, authenticated user, user settings etcetera.
@@ -39,7 +39,7 @@ app.use(function (req, res, next) {
3939

4040
### res.req
4141

42-
This property holds a reference to the <a href="#request">request object</a>
42+
This property holds a reference to the [request object](../request/)
4343
that relates to this response object.
4444

4545
## Methods
@@ -106,7 +106,7 @@ to sign the value.
106106
res.cookie('name', 'tobi', { signed: true });
107107
```
108108

109-
Later you may access this value through the <a href="#req.signedCookies">req.signedCookie</a>
109+
Later you may access this value through the [req.signedCookie](../request/#reqsignedcookies)
110110
object.
111111

112112
### res.download(path, [filename], [fn])
@@ -230,7 +230,7 @@ res.jsonp(500, { error: 'message' });
230230
```
231231

232232
By default the JSONP callback name is simply `callback`,
233-
however you may alter this with the <a href="#app-settings">jsonp callback name</a>
233+
however you may alter this with the [jsonp callback name](../application/#settings)
234234
setting. The following are some examples of JSONP responses using the same
235235
code:
236236

src/content/api/4x/api/application/index.mdx

Lines changed: 23 additions & 23 deletions
Large diffs are not rendered by default.

src/content/api/4x/api/express/index.mdx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var app = express();
2020

2121
This is a built-in middleware function in Express. It parses incoming requests
2222
with JSON payloads and is based on
23-
[body-parser](/en/resources/middleware/body-parser).
23+
[body-parser](../../../resources/middleware/body-parser).
2424

2525
Returns middleware that only parses JSON and only looks at requests where
2626
the `Content-Type` header matches the `type` option. This parser accepts any
@@ -62,7 +62,7 @@ The following table describes the properties of the optional `options` object.
6262

6363
This is a built-in middleware function in Express. It parses incoming request
6464
payloads into a `Buffer` and is based on
65-
[body-parser](/en/resources/middleware/body-parser).
65+
[body-parser](../../../resources/middleware/body-parser).
6666

6767
Returns middleware that parses all bodies as a `Buffer` and only looks at requests
6868
where the `Content-Type` header matches the `type` option. This parser accepts
@@ -98,7 +98,7 @@ The following table describes the properties of the optional `options` object.
9898

9999
### express.Router([options])
100100

101-
Creates a new [router](#router) object.
101+
Creates a new [router](../router/) object.
102102

103103
```js
104104
var router = express.Router([options]);
@@ -119,17 +119,17 @@ The optional `options` parameter specifies the behavior of the router.
119119
You can add middleware and HTTP method routes (such as `get`, `put`, `post`, and
120120
so on) to `router` just like an application.
121121

122-
For more information, see [Router](#router).
122+
For more information, see [Router](../router/).
123123

124124
### express.static(root, [options])
125125

126126
This is a built-in middleware function in Express.
127-
It serves static files and is based on [serve-static](/en/resources/middleware/serve-static).
127+
It serves static files and is based on [serve-static](../../../resources/middleware/serve-static).
128128

129129
<Alert type="info">
130130

131131
For best results, [use a reverse
132-
proxy](/en/advanced/best-practice-performance#use-a-reverse-proxy) cache to improve performance of
132+
proxy](../../../advanced/best-practice-performance#use-a-reverse-proxy) cache to improve performance of
133133
serving static assets.
134134

135135
</Alert>
@@ -161,8 +161,8 @@ See also the [example below](#example-of-expressstatic).
161161

162162
</div>
163163

164-
For more information, see [Serving static files in Express](/en/starter/static-files).
165-
and [Using middleware - Built-in middleware](/en/guide/using-middleware#middleware.built-in).
164+
For more information, see [Serving static files in Express](../../starter/static-files).
165+
and [Using middleware - Built-in middleware](../../guide/using-middleware/#built-in-middleware).
166166

167167
#### dotfiles
168168

@@ -198,7 +198,7 @@ fn(res, path, stat);
198198

199199
Arguments:
200200

201-
- `res`, the [response object](#res).
201+
- `res`, the [response object](../response/).
202202
- `path`, the file path that is being sent.
203203
- `stat`, the `stat` object of the file that is being sent.
204204

@@ -228,7 +228,7 @@ app.use(express.static('public', options));
228228

229229
This is a built-in middleware function in Express. It parses incoming request
230230
payloads into a string and is based on
231-
[body-parser](/en/resources/middleware/body-parser).
231+
[body-parser](../../../resources/middleware/body-parser).
232232

233233
Returns middleware that parses all bodies as a string and only looks at requests
234234
where the `Content-Type` header matches the `type` option. This parser accepts
@@ -268,7 +268,7 @@ The following table describes the properties of the optional `options` object.
268268
<Alert type="info">This middleware is available in Express v4.16.0 onwards.</Alert>
269269

270270
This is a built-in middleware function in Express. It parses incoming requests
271-
with urlencoded payloads and is based on [body-parser](/en/resources/middleware/body-parser).
271+
with urlencoded payloads and is based on [body-parser](../../../resources/middleware/body-parser).
272272

273273
Returns middleware that only parses urlencoded bodies and only looks at
274274
requests where the `Content-Type` header matches the `type` option. This

src/content/api/4x/api/request/index.mdx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ module.exports = function (req, res) {
6767

6868
The URL path on which a router instance was mounted.
6969

70-
The `req.baseUrl` property is similar to the [mountpath](#app.mountpath) property of the `app` object,
70+
The `req.baseUrl` property is similar to the [mountpath](../application/#appmountpath) property of the `app` object,
7171
except `app.mountpath` returns the matched path pattern(s).
7272

7373
For example:
@@ -98,7 +98,7 @@ made to `/hello/jp`, `req.baseUrl` is "/hello".
9898

9999
Contains key-value pairs of data submitted in the request body.
100100
By default, it is `undefined`, and is populated when you use body-parsing middleware such
101-
as [`express.json()`](#express.json) or [`express.urlencoded()`](#express.urlencoded).
101+
as [`express.json()`](../express/#expressjsonoptions) or [`express.urlencoded()`](../express/#expressurlencodedoptions).
102102

103103
<Alert type="warning">
104104

@@ -158,7 +158,7 @@ console.dir(req.fresh);
158158

159159
Contains the hostname derived from the `Host` HTTP header.
160160

161-
When the [`trust proxy` setting](/en/4x/api#trust.proxy.options.table)
161+
When the [`trust proxy` setting](../application/#options-for-trust-proxy-setting)
162162
does not evaluate to `false`, this property will instead get the value
163163
from the `X-Forwarded-Host` header field. This header can be set by
164164
the client or by the proxy.
@@ -184,7 +184,7 @@ console.dir(req.hostname);
184184

185185
Contains the remote IP address of the request.
186186

187-
When the [`trust proxy` setting](/en/4x/api#trust.proxy.options.table) does not evaluate to `false`,
187+
When the [`trust proxy` setting](../application/#options-for-trust-proxy-setting) does not evaluate to `false`,
188188
the value of this property is derived from the left-most entry in the
189189
`X-Forwarded-For` header. This header can be set by the client or by the proxy.
190190

@@ -195,7 +195,7 @@ console.dir(req.ip);
195195

196196
### req.ips
197197

198-
When the [`trust proxy` setting](/en/4x/api#trust.proxy.options.table) does not evaluate to `false`,
198+
When the [`trust proxy` setting](../application/#options-for-trust-proxy-setting) does not evaluate to `false`,
199199
this property contains an array of IP addresses
200200
specified in the `X-Forwarded-For` request header. Otherwise, it contains an
201201
empty array. This header can be set by the client or by the proxy.
@@ -219,7 +219,7 @@ module](https://nodejs.org/api/http.html#http_message_url).
219219

220220
This property is much like `req.url`; however, it retains the original request URL,
221221
allowing you to rewrite `req.url` freely for internal routing purposes. For example,
222-
the "mounting" feature of [app.use()](#app.use) will rewrite `req.url` to strip the mount point.
222+
the "mounting" feature of [app.use()](../application/#appusepath-callback--callback) will rewrite `req.url` to strip the mount point.
223223

224224
```js
225225
// GET /search?q=something
@@ -242,7 +242,7 @@ app.use('/admin', function (req, res, next) {
242242

243243
### req.params
244244

245-
This property is an object containing properties mapped to the [named route "parameters"](/en/guide/routing#route-parameters). For example, if you have the route `/user/:name`, then the "name" property is available as `req.params.name`. This object defaults to `{}`.
245+
This property is an object containing properties mapped to the [named route "parameters"](../../guide/routing/#route-parameters). For example, if you have the route `/user/:name`, then the "name" property is available as `req.params.name`. This object defaults to `{}`.
246246

247247
```js
248248
// GET /user/tj
@@ -260,7 +260,7 @@ console.dir(req.params[0]);
260260

261261
Named capturing groups in regular expressions behave like named route parameters. For example the group from `/^\/file\/(?<path>.*)$/` expression is available as `req.params.path`.
262262

263-
If you need to make changes to a key in `req.params`, use the [app.param](/en/4x/api#app.param) handler. Changes are applicable only to [parameters](/en/guide/routing#route-parameters) already defined in the route path.
263+
If you need to make changes to a key in `req.params`, use the [app.param](../application/#appparamname-callback) handler. Changes are applicable only to [parameters](../../guide/routing/#route-parameters) already defined in the route path.
264264

265265
Any changes made to the `req.params` object in a middleware or route handler will be reset.
266266

@@ -283,15 +283,15 @@ console.dir(req.path);
283283
<Alert type="info">
284284

285285
When called from a middleware, the mount point is not included in `req.path`. See
286-
[app.use()](/en/4x/api#app.use) for more details.
286+
[app.use()](../application/#appusepath-callback--callback) for more details.
287287

288288
</Alert>
289289

290290
### req.protocol
291291

292292
Contains the request protocol string: either `http` or (for TLS requests) `https`.
293293

294-
When the [`trust proxy` setting](#trust.proxy.options.table) does not evaluate to `false`,
294+
When the [`trust proxy` setting](../application/#options-for-trust-proxy-setting) does not evaluate to `false`,
295295
this property will use the value of the `X-Forwarded-Proto` header field if present.
296296
This header can be set by the client or by the proxy.
297297

@@ -303,7 +303,7 @@ console.dir(req.protocol);
303303
### req.query
304304

305305
This property is an object containing a property for each query string parameter in the route.
306-
When [query parser](/en/api/application/app-set#app.settings.table) is set to disabled, it is an empty object `{}`, otherwise it is the result of the configured query parser.
306+
When [query parser](../application/#application-settings) is set to disabled, it is an empty object `{}`, otherwise it is the result of the configured query parser.
307307

308308
<Alert type="warning">
309309

@@ -314,7 +314,7 @@ may not be a function and instead a string or other user-input.
314314

315315
</Alert>
316316

317-
The value of this property can be configured with the [query parser application setting](/en/api/application/app-set#app.settings.table) to work how your application needs it. A very popular query string parser is the [`qs` module](https://www.npmjs.org/package/qs), and this is used by default. The `qs` module is very configurable with many settings, and it may be desirable to use different settings than the default to populate `req.query`:
317+
The value of this property can be configured with the [query parser application setting](../application/#application-settings) to work how your application needs it. A very popular query string parser is the [`qs` module](https://www.npmjs.org/package/qs), and this is used by default. The `qs` module is very configurable with many settings, and it may be desirable to use different settings than the default to populate `req.query`:
318318

319319
```js
320320
var qs = require('qs');
@@ -325,11 +325,11 @@ app.set('query parser', function (str) {
325325
});
326326
```
327327

328-
Check out the [query parser application setting](/en/api/application/app-set#app.settings.table) documentation for other customization options.
328+
Check out the [query parser application setting](../application/#application-settings) documentation for other customization options.
329329

330330
### req.res
331331

332-
This property holds a reference to the <a href="#res">response object</a>
332+
This property holds a reference to the [response object](../response)
333333
that relates to this request object.
334334

335335
### req.route
@@ -407,7 +407,7 @@ console.dir(req.subdomains);
407407

408408
The application property `subdomain offset`, which defaults to 2, is used for determining the
409409
beginning of the subdomain segments. To change this behavior, change its value
410-
using [app.set](/en/4x/api#app.set).
410+
using [app.set](../application/#appsetname-value).
411411

412412
### req.xhr
413413

src/content/api/4x/api/response/index.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ and supports all [built-in fields and methods](https://nodejs.org/api/http.html#
3636

3737
This property holds a reference to the instance of the Express application that is using the middleware.
3838

39-
`res.app` is identical to the [req.app](#req.app) property in the request object.
39+
`res.app` is identical to the [req.app](../request/#reqapp) property in the request object.
4040

4141
### res.headersSent
4242

@@ -52,7 +52,7 @@ app.get('/', function (req, res) {
5252

5353
### res.locals
5454

55-
Use this property to set variables accessible in templates rendered with [res.render](#resrenderview-locals-callback).
55+
Use this property to set variables accessible in templates rendered with [res.render](#resrenderview--locals--callback).
5656
The variables set on `res.locals` are available within a single request-response cycle, and will not
5757
be shared between requests.
5858

@@ -66,7 +66,7 @@ for the used view engine for additional considerations.
6666
</Alert>
6767

6868
In order to keep local variables for use in template rendering between requests, use
69-
[app.locals](#app.locals) instead.
69+
[app.locals](../application/#applocals) instead.
7070

7171
This property is useful for exposing request-level information such as the request path name,
7272
authenticated user, user settings, and so on to templates rendered within the application.
@@ -82,7 +82,7 @@ app.use(function (req, res, next) {
8282

8383
### res.req
8484

85-
This property holds a reference to the <a href="#req">request object</a>
85+
This property holds a reference to the [request object](../request/)
8686
that relates to this response object.
8787

8888
## Methods
@@ -238,7 +238,7 @@ Then `res.cookie()` will use the secret passed to `cookieParser(secret)` to sign
238238
res.cookie('name', 'tobi', { signed: true });
239239
```
240240

241-
Later you may access this value through the [req.signedCookie](#req.signedCookies) object.
241+
Later you may access this value through the [req.signedCookie](../request/#reqsignedcookies) object.
242242

243243
### res.download(path [, filename] [, options] [, fn])
244244

@@ -310,7 +310,7 @@ res.status(404).end();
310310
### res.format(object)
311311

312312
Performs content-negotiation on the `Accept` HTTP header on the request object, when present.
313-
It uses [req.accepts()](#req.accepts) to select a handler for the request, based on the acceptable
313+
It uses [req.accepts()](../request/#reqacceptstypes) to select a handler for the request, based on the acceptable
314314
types ordered by their quality values. If the header is not specified, the first callback is invoked.
315315
When no match is found, the server responds with 406 "Not Acceptable", or invokes the `default` callback.
316316

@@ -402,7 +402,7 @@ res.status(500).jsonp({ error: 'message' });
402402

403403
By default, the JSONP callback name is simply `callback`. Override this with the
404404

405-
<a href="/api/application/app-settings/">jsonp callback name</a> setting.
405+
[jsonp callback name](../application/#application-settings) setting.
406406

407407
The following are some examples of JSONP responses using the same code:
408408

@@ -458,7 +458,7 @@ res.location('back');
458458
A `path` value of "back" has a special meaning, it refers to the URL specified in the `Referer` header of the request. If the `Referer` header was not specified, it refers to "/".
459459

460460
See also [Security best practices: Prevent open redirect
461-
vulnerabilities](http://expressjs.com/en/advanced/best-practice-security#prevent-open-redirects).
461+
vulnerabilities](../../../advanced/best-practice-security/#prevent-open-redirects).
462462

463463
<Alert type="warning">
464464
After encoding the URL, if not encoded already, Express passes the specified URL to the browser in the `Location` header,
@@ -532,7 +532,7 @@ res.redirect('back');
532532
</Alert>
533533

534534
See also [Security best practices: Prevent open redirect
535-
vulnerabilities](http://expressjs.com/en/advanced/best-practice-security#prevent-open-redirects).
535+
vulnerabilities](../../../advanced/best-practice-security/#prevent-open-redirects).
536536

537537
### res.render(view [, locals] [, callback])
538538

@@ -544,7 +544,7 @@ Optional parameters:
544544

545545
The `view` argument is a string that is the file path of the view file to render. This can be an absolute path, or a path relative to the `views` setting. If the path does not contain a file extension, then the `view engine` setting determines the file extension. If the path does contain a file extension, then Express will load the module for the specified template engine (via `require()`) and render it using the loaded module's `__express` function.
546546

547-
For more information, see [Using template engines with Express](/en/guide/using-template-engines).
547+
For more information, see [Using template engines with Express](../../guide/using-template-engines).
548548

549549
<Alert type="warning">
550550

src/content/api/4x/api/router/index.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ as a "mini-application," capable only of performing middleware and routing
1010
functions. Every Express application has a built-in app router.
1111

1212
A router behaves like middleware itself, so you can use it as an argument to
13-
[app.use()](/en/4x/api/application#appusepath-callback--callback) or as the argument to another router's [use()](#routerusepath-function--function) method.
13+
[app.use()](../application#appusepath-callback--callback) or as the argument to another router's [use()](#routerusepath-function--function) method.
1414

15-
The top-level `express` object has a [Router()](/en/4x/api/express#expressrouteroptions) method that creates a new `router` object.
15+
The top-level `express` object has a [Router()](../express#expressrouteroptions) method that creates a new `router` object.
1616

1717
Once you've created a router object, you can add middleware and HTTP method routes (such as `get`, `put`, `post`,
1818
and so on) to it just like an application. For example:
@@ -306,8 +306,8 @@ belong to the route to which they were added.
306306

307307
Uses the specified middleware function or functions, with optional mount path `path`, that defaults to "/".
308308

309-
This method is similar to [app.use()](/en/4x/api/application#appusepath-callback--callback). A simple example and use case is described below.
310-
See [app.use()](/en/4x/api/application#appusepath-callback--callback) for more information.
309+
This method is similar to [app.use()](../application#appusepath-callback--callback). A simple example and use case is described below.
310+
See [app.use()](../application#appusepath-callback--callback) for more information.
311311

312312
Middleware is like a plumbing pipe: requests start at the first middleware function defined
313313
and work their way "down" the middleware stack processing for each path they match.

0 commit comments

Comments
 (0)