@docusaurus/plugin-client-redirects 3.10.1-canary-6655 → 3.10.1-canary-6803
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
|
@@ -70,10 +70,10 @@ function validateCollectedRedirects(redirects, pluginContext) {
|
|
|
70
70
|
// See https://github.com/facebook/docusaurus/issues/6845
|
|
71
71
|
.map((to) => {
|
|
72
72
|
if (to.startsWith('/')) {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
const url = URL.parse(to, 'https://example.com');
|
|
74
|
+
if (url) {
|
|
75
|
+
return decodeURI(url.pathname);
|
|
75
76
|
}
|
|
76
|
-
catch { }
|
|
77
77
|
}
|
|
78
78
|
return undefined;
|
|
79
79
|
})
|
|
@@ -9,24 +9,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.default = createRedirectPageContent;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
|
-
const
|
|
12
|
+
const eta_1 = require("eta");
|
|
13
13
|
const redirectPage_template_html_1 = tslib_1.__importDefault(require("./templates/redirectPage.template.html"));
|
|
14
|
+
const eta = new eta_1.Eta();
|
|
14
15
|
const getCompiledRedirectPageTemplate = lodash_1.default.memoize(() => eta.compile(redirectPage_template_html_1.default.trim()));
|
|
15
16
|
function renderRedirectPageTemplate(data) {
|
|
16
17
|
const compiled = getCompiledRedirectPageTemplate();
|
|
17
|
-
return compiled
|
|
18
|
+
return eta.render(compiled, data);
|
|
18
19
|
}
|
|
19
20
|
// if the target url does not include ?search#anchor,
|
|
20
21
|
// we forward search/anchor that the redirect page receives
|
|
21
22
|
function searchAnchorForwarding(toUrl) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const containsSearchOrAnchor = url.search || url.hash;
|
|
25
|
-
return !containsSearchOrAnchor;
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
23
|
+
const url = URL.parse(toUrl, 'https://example.com');
|
|
24
|
+
if (url === null) {
|
|
28
25
|
return false;
|
|
29
26
|
}
|
|
27
|
+
const containsSearchOrAnchor = url.search || url.hash;
|
|
28
|
+
return !containsSearchOrAnchor;
|
|
30
29
|
}
|
|
31
30
|
function createRedirectPageContent({ toUrl, }) {
|
|
32
31
|
return renderRedirectPageTemplate({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-client-redirects",
|
|
3
|
-
"version": "3.10.1-canary-
|
|
3
|
+
"version": "3.10.1-canary-6803",
|
|
4
4
|
"description": "Client redirects plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "3.10.1-canary-
|
|
22
|
-
"@docusaurus/logger": "3.10.1-canary-
|
|
23
|
-
"@docusaurus/utils": "3.10.1-canary-
|
|
24
|
-
"@docusaurus/utils-common": "3.10.1-canary-
|
|
25
|
-
"@docusaurus/utils-validation": "3.10.1-canary-
|
|
26
|
-
"eta": "^
|
|
21
|
+
"@docusaurus/core": "3.10.1-canary-6803",
|
|
22
|
+
"@docusaurus/logger": "3.10.1-canary-6803",
|
|
23
|
+
"@docusaurus/utils": "3.10.1-canary-6803",
|
|
24
|
+
"@docusaurus/utils-common": "3.10.1-canary-6803",
|
|
25
|
+
"@docusaurus/utils-validation": "3.10.1-canary-6803",
|
|
26
|
+
"eta": "^4.0.1",
|
|
27
27
|
"fs-extra": "^11.2.0",
|
|
28
28
|
"lodash": "^4.17.21",
|
|
29
29
|
"tslib": "^2.6.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@docusaurus/types": "3.10.1-canary-
|
|
32
|
+
"@docusaurus/types": "3.10.1-canary-6803"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^19.2.5",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=24.14"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "d2c7b381512bd4e7e90e33f56649e68d618eaa92"
|
|
42
42
|
}
|
package/src/collectRedirects.ts
CHANGED
|
@@ -99,9 +99,10 @@ function validateCollectedRedirects(
|
|
|
99
99
|
// See https://github.com/facebook/docusaurus/issues/6845
|
|
100
100
|
.map((to) => {
|
|
101
101
|
if (to.startsWith('/')) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
const url = URL.parse(to, 'https://example.com');
|
|
103
|
+
if (url) {
|
|
104
|
+
return decodeURI(url.pathname);
|
|
105
|
+
}
|
|
105
106
|
}
|
|
106
107
|
return undefined;
|
|
107
108
|
})
|
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import _ from 'lodash';
|
|
9
|
-
import
|
|
9
|
+
import {Eta} from 'eta';
|
|
10
10
|
import redirectPageTemplate from './templates/redirectPage.template.html';
|
|
11
11
|
|
|
12
|
+
const eta = new Eta();
|
|
13
|
+
|
|
12
14
|
const getCompiledRedirectPageTemplate = _.memoize(() =>
|
|
13
15
|
eta.compile(redirectPageTemplate.trim()),
|
|
14
16
|
);
|
|
@@ -18,19 +20,18 @@ function renderRedirectPageTemplate(data: {
|
|
|
18
20
|
searchAnchorForwarding: boolean;
|
|
19
21
|
}) {
|
|
20
22
|
const compiled = getCompiledRedirectPageTemplate();
|
|
21
|
-
return compiled
|
|
23
|
+
return eta.render(compiled, data);
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
// if the target url does not include ?search#anchor,
|
|
25
27
|
// we forward search/anchor that the redirect page receives
|
|
26
28
|
function searchAnchorForwarding(toUrl: string): boolean {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const containsSearchOrAnchor = url.search || url.hash;
|
|
30
|
-
return !containsSearchOrAnchor;
|
|
31
|
-
} catch {
|
|
29
|
+
const url = URL.parse(toUrl, 'https://example.com');
|
|
30
|
+
if (url === null) {
|
|
32
31
|
return false;
|
|
33
32
|
}
|
|
33
|
+
const containsSearchOrAnchor = url.search || url.hash;
|
|
34
|
+
return !containsSearchOrAnchor;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
export default function createRedirectPageContent({
|
package/src/deps.d.ts
CHANGED
|
@@ -4,13 +4,3 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
// TODO incompatible declaration file
|
|
9
|
-
declare module 'eta' {
|
|
10
|
-
export const defaultConfig: object;
|
|
11
|
-
|
|
12
|
-
export function compile(
|
|
13
|
-
template: string,
|
|
14
|
-
options?: object,
|
|
15
|
-
): (data: object, config: object) => string;
|
|
16
|
-
}
|