Skip to content

Commit ec94d0c

Browse files
dancastilloflakey5
authored andcommitted
docs: fix broken links in undici webpage (nodejs#3807)
1 parent 68ef190 commit ec94d0c

File tree

8 files changed

+45
-10
lines changed

8 files changed

+45
-10
lines changed

docs/docs/api/BalancedPool.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Extends: `undici.Dispatcher`
44

5-
A pool of [Pool](Pool.md) instances connected to multiple upstreams.
5+
A pool of [Pool](/docs/docs/api/Pool.md) instances connected to multiple upstreams.
66

77
Requests are not guaranteed to be dispatched in order of invocation.
88

docs/docs/api/MockClient.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Extends: `undici.Client`
44

5-
A mock client class that implements the same api as [MockPool](MockPool.md).
5+
A mock client class that implements the same api as [MockPool](/docs/docs/api/MockPool.md).
66

77
## `new MockClient(origin, [options])`
88

docs/docs/api/Pool.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Extends: `undici.Dispatcher`
44

5-
A pool of [Client](Client.md) instances connected to the same upstream target.
5+
A pool of [Client](/docs/docs/api/Client.md) instances connected to the same upstream target.
66

77
Requests are not guaranteed to be dispatched in order of invocation.
88

docs/docs/api/api-lifecycle.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Client Lifecycle
22

3-
An Undici [Client](Client.md) can be best described as a state machine. The following list is a summary of the various state transitions the `Client` will go through in its lifecycle. This document also contains detailed breakdowns of each state.
3+
An Undici [Client](/docs/docs/api/Client.md) can be best described as a state machine. The following list is a summary of the various state transitions the `Client` will go through in its lifecycle. This document also contains detailed breakdowns of each state.
44

55
> This diagram is not a perfect representation of the undici Client. Since the Client class is not actually implemented as a state-machine, actual execution may deviate slightly from what is described below. Consider this as a general resource for understanding the inner workings of the Undici client rather than some kind of formal specification.
66
@@ -28,7 +28,7 @@ stateDiagram-v2
2828
[*] --> idle
2929
idle --> pending : connect
3030
idle --> destroyed : destroy/close
31-
31+
3232
pending --> idle : timeout
3333
pending --> destroyed : destroy
3434

docs/docs/best-practices/mocking-request.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Mocking Request
22

3-
Undici has its own mocking [utility](../api/MockAgent.md). It allow us to intercept undici HTTP requests and return mocked values instead. It can be useful for testing purposes.
3+
Undici has its own mocking [utility](/docs/docs/api/MockAgent.md). It allow us to intercept undici HTTP requests and return mocked values instead. It can be useful for testing purposes.
44

55
Example:
66

@@ -73,7 +73,7 @@ const badRequest = await bankTransfer('1234567890', '100')
7373
assert.deepEqual(badRequest, { message: 'bank account not found' })
7474
```
7575

76-
Explore other MockAgent functionality [here](../api/MockAgent.md)
76+
Explore other MockAgent functionality [here](/docs/docs/api/MockAgent.md)
7777

7878
## Debug Mock Value
7979

docs/docs/best-practices/proxy.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Connecting through a proxy is possible by:
44

5-
- Using [ProxyAgent](../api/ProxyAgent.md).
5+
- Using [ProxyAgent](/docs/docs/api/ProxyAgent.md).
66
- Configuring `Client` or `Pool` constructor.
77

88
The proxy url should be passed to the `Client` or `Pool` constructor, while the upstream server url

docs/docsify/sidebar.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* [MockErrors](/docs/api/MockErrors.md "Undici API - MockErrors")
2121
* [API Lifecycle](/docs/api/api-lifecycle.md "Undici API - Lifecycle")
2222
* [Diagnostics Channel Support](/docs/api/DiagnosticsChannel.md "Diagnostics Channel Support")
23-
* [Debug](/docs/api/Debug.md.md "Undici API - Debugging Undici")
23+
* [Debug](/docs/api/Debug.md "Undici API - Debugging Undici")
2424
* [WebSocket](/docs/api/WebSocket.md "Undici API - WebSocket")
2525
* [MIME Type Parsing](/docs/api/ContentType.md "Undici API - MIME Type Parsing")
2626
* [CacheStorage](/docs/api/CacheStorage.md "Undici API - CacheStorage")

docs/index.html

+36-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,42 @@
3232
noCompileLinks: [
3333
'benchmarks/.*'
3434
],
35-
relativePath: true
35+
relativePath: true,
36+
markdown: {
37+
renderer: {
38+
// Mimic markedjs/marked behavior just modify href - https://github.com/markedjs/marked/blob/master/src/Renderer.ts#L178-L191
39+
link(href, title, text) {
40+
const originalHref = href;
41+
42+
if (href.startsWith('./')) {
43+
// Use absolute path (e.g. ./docs/api.md => /docs/api.md) if href starts with ./ (e.g. ./api.md)
44+
href = href.slice(1);
45+
}
46+
47+
// Check for /docs/docs/ in the href and remove duplication it if present
48+
href = href.startsWith('/docs/docs/') ? href.replace('/docs/', '/') : href;
49+
50+
// Check for /docs/ in the href and remove it if present
51+
if (href.startsWith('/docs/')) {
52+
// ignore paths /docs/api/ and /docs/best-practices/ in /docs/docs directory
53+
if (!/^(\/docs\/(?:api|best-practices))(?:\/|$)/.test(href)) {
54+
href = href.includes('/docs/') ? href.replace('/docs/', '/') : href;
55+
}
56+
}
57+
58+
let target = '';
59+
if (originalHref.startsWith('http')) {
60+
// External link - default behavior is to open in a new window
61+
return `<a href="${originalHref}" ${title}" target="_blank" rel="noopener noreferrer">${text}</a>`;
62+
}
63+
64+
title = title ? `title="${title}"` : '';
65+
let out = `<a href="#${href}" ${title}">${text}</a>`;
66+
67+
return out;
68+
},
69+
},
70+
},
3671
}
3772
</script>
3873
<!-- Docsify v4 -->

0 commit comments

Comments
 (0)