@docusaurus/plugin-client-redirects 3.10.1-canary-6655 → 3.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/collectRedirects.js
CHANGED
|
@@ -14,14 +14,6 @@ const utils_common_1 = require("@docusaurus/utils-common");
|
|
|
14
14
|
const extensionRedirects_1 = require("./extensionRedirects");
|
|
15
15
|
const redirectValidation_1 = require("./redirectValidation");
|
|
16
16
|
function collectRedirects(pluginContext, trailingSlash) {
|
|
17
|
-
function normalizeRedirectTo(to) {
|
|
18
|
-
return to.startsWith('/')
|
|
19
|
-
? (0, utils_common_1.applyTrailingSlash)(to, {
|
|
20
|
-
trailingSlash,
|
|
21
|
-
baseUrl: pluginContext.baseUrl,
|
|
22
|
-
})
|
|
23
|
-
: to;
|
|
24
|
-
}
|
|
25
17
|
// For each plugin config option, create the appropriate redirects
|
|
26
18
|
const redirects = [
|
|
27
19
|
...(0, extensionRedirects_1.createFromExtensionsRedirects)(pluginContext.relativeRoutesPaths, pluginContext.options.fromExtensions),
|
|
@@ -39,7 +31,10 @@ function collectRedirects(pluginContext, trailingSlash) {
|
|
|
39
31
|
//
|
|
40
32
|
// It should be easy to toggle `trailingSlash` option without having to
|
|
41
33
|
// change other configs
|
|
42
|
-
to:
|
|
34
|
+
to: (0, utils_common_1.applyTrailingSlash)(redirect.to, {
|
|
35
|
+
trailingSlash,
|
|
36
|
+
baseUrl: pluginContext.baseUrl,
|
|
37
|
+
}),
|
|
43
38
|
}));
|
|
44
39
|
validateCollectedRedirects(redirects, pluginContext);
|
|
45
40
|
return filterUnwantedRedirects(redirects, pluginContext);
|
|
@@ -73,7 +68,7 @@ function validateCollectedRedirects(redirects, pluginContext) {
|
|
|
73
68
|
try {
|
|
74
69
|
return decodeURI(new URL(to, 'https://example.com').pathname);
|
|
75
70
|
}
|
|
76
|
-
catch { }
|
|
71
|
+
catch (e) { }
|
|
77
72
|
}
|
|
78
73
|
return undefined;
|
|
79
74
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-client-redirects",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.2",
|
|
4
4
|
"description": "Client redirects plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -18,25 +18,25 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "3.10.
|
|
22
|
-
"@docusaurus/logger": "3.10.
|
|
23
|
-
"@docusaurus/utils": "3.10.
|
|
24
|
-
"@docusaurus/utils-common": "3.10.
|
|
25
|
-
"@docusaurus/utils-validation": "3.10.
|
|
21
|
+
"@docusaurus/core": "3.10.2",
|
|
22
|
+
"@docusaurus/logger": "3.10.2",
|
|
23
|
+
"@docusaurus/utils": "3.10.2",
|
|
24
|
+
"@docusaurus/utils-common": "3.10.2",
|
|
25
|
+
"@docusaurus/utils-validation": "3.10.2",
|
|
26
26
|
"eta": "^2.2.0",
|
|
27
|
-
"fs-extra": "^11.
|
|
27
|
+
"fs-extra": "^11.1.1",
|
|
28
28
|
"lodash": "^4.17.21",
|
|
29
29
|
"tslib": "^2.6.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@docusaurus/types": "3.10.
|
|
32
|
+
"@docusaurus/types": "3.10.2"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"react": "^19.
|
|
36
|
-
"react-dom": "^19.
|
|
35
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
36
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
|
-
"node": ">=
|
|
39
|
+
"node": ">=20.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "f37f9035584917a97a260b91fc2842cba4f8b94f"
|
|
42
42
|
}
|
package/src/collectRedirects.ts
CHANGED
|
@@ -24,15 +24,6 @@ export default function collectRedirects(
|
|
|
24
24
|
pluginContext: PluginContext,
|
|
25
25
|
trailingSlash: boolean | undefined,
|
|
26
26
|
): RedirectItem[] {
|
|
27
|
-
function normalizeRedirectTo(to: string) {
|
|
28
|
-
return to.startsWith('/')
|
|
29
|
-
? applyTrailingSlash(to, {
|
|
30
|
-
trailingSlash,
|
|
31
|
-
baseUrl: pluginContext.baseUrl,
|
|
32
|
-
})
|
|
33
|
-
: to;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
27
|
// For each plugin config option, create the appropriate redirects
|
|
37
28
|
const redirects = [
|
|
38
29
|
...createFromExtensionsRedirects(
|
|
@@ -59,7 +50,10 @@ export default function collectRedirects(
|
|
|
59
50
|
//
|
|
60
51
|
// It should be easy to toggle `trailingSlash` option without having to
|
|
61
52
|
// change other configs
|
|
62
|
-
to:
|
|
53
|
+
to: applyTrailingSlash(redirect.to, {
|
|
54
|
+
trailingSlash,
|
|
55
|
+
baseUrl: pluginContext.baseUrl,
|
|
56
|
+
}),
|
|
63
57
|
}));
|
|
64
58
|
|
|
65
59
|
validateCollectedRedirects(redirects, pluginContext);
|
|
@@ -101,7 +95,7 @@ function validateCollectedRedirects(
|
|
|
101
95
|
if (to.startsWith('/')) {
|
|
102
96
|
try {
|
|
103
97
|
return decodeURI(new URL(to, 'https://example.com').pathname);
|
|
104
|
-
} catch {}
|
|
98
|
+
} catch (e) {}
|
|
105
99
|
}
|
|
106
100
|
return undefined;
|
|
107
101
|
})
|
|
@@ -28,7 +28,7 @@ function searchAnchorForwarding(toUrl: string): boolean {
|
|
|
28
28
|
const url = new URL(toUrl, 'https://example.com');
|
|
29
29
|
const containsSearchOrAnchor = url.search || url.hash;
|
|
30
30
|
return !containsSearchOrAnchor;
|
|
31
|
-
} catch {
|
|
31
|
+
} catch (e) {
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
}
|