@docusaurus/plugin-client-redirects 0.0.0-4279 → 0.0.0-4286
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/package.json +7 -7
- package/lib/.tsbuildinfo +0 -1
- package/src/__tests__/__snapshots__/collectRedirects.test.ts.snap +0 -27
- package/src/__tests__/__snapshots__/createRedirectPageContent.test.ts.snap +0 -29
- package/src/__tests__/__snapshots__/normalizePluginOptions.test.ts.snap +0 -35
- package/src/__tests__/__snapshots__/redirectValidation.test.ts.snap +0 -11
- package/src/__tests__/__snapshots__/writeRedirectFiles.test.ts.snap +0 -147
- package/src/__tests__/collectRedirects.test.ts +0 -338
- package/src/__tests__/createRedirectPageContent.test.ts +0 -26
- package/src/__tests__/extensionRedirects.test.ts +0 -143
- package/src/__tests__/normalizePluginOptions.test.ts +0 -71
- package/src/__tests__/redirectValidation.test.ts +0 -66
- package/src/__tests__/writeRedirectFiles.test.ts +0 -205
- package/tsconfig.json +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-client-redirects",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4286",
|
|
4
4
|
"description": "Client redirects plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-client-redirects.d.ts",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "0.0.0-
|
|
22
|
-
"@docusaurus/utils": "0.0.0-
|
|
23
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
24
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
21
|
+
"@docusaurus/core": "0.0.0-4286",
|
|
22
|
+
"@docusaurus/utils": "0.0.0-4286",
|
|
23
|
+
"@docusaurus/utils-common": "0.0.0-4286",
|
|
24
|
+
"@docusaurus/utils-validation": "0.0.0-4286",
|
|
25
25
|
"chalk": "^4.1.2",
|
|
26
26
|
"eta": "^1.12.3",
|
|
27
27
|
"fs-extra": "^10.0.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"tslib": "^2.3.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@docusaurus/types": "0.0.0-
|
|
32
|
+
"@docusaurus/types": "0.0.0-4286"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^16.8.4 || ^17.0.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=14"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "2a87bcff19729fff3df8fe20ca79fcac87b31371"
|
|
42
42
|
}
|
package/lib/.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"program":{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/typescript/lib/lib.esnext.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/tslib/tslib.d.ts","../../../node_modules/@types/lodash/common/common.d.ts","../../../node_modules/@types/lodash/common/array.d.ts","../../../node_modules/@types/lodash/common/collection.d.ts","../../../node_modules/@types/lodash/common/date.d.ts","../../../node_modules/@types/lodash/common/function.d.ts","../../../node_modules/@types/lodash/common/lang.d.ts","../../../node_modules/@types/lodash/common/math.d.ts","../../../node_modules/@types/lodash/common/number.d.ts","../../../node_modules/@types/lodash/common/object.d.ts","../../../node_modules/@types/lodash/common/seq.d.ts","../../../node_modules/@types/lodash/common/string.d.ts","../../../node_modules/@types/lodash/common/util.d.ts","../../../node_modules/@types/lodash/index.d.ts","../../../node_modules/@types/estree/index.d.ts","../../../node_modules/@types/json-schema/index.d.ts","../../../node_modules/schema-utils/declarations/ValidationError.d.ts","../../../node_modules/ajv/lib/ajv.d.ts","../../../node_modules/schema-utils/declarations/validate.d.ts","../../../node_modules/schema-utils/declarations/index.d.ts","../../../node_modules/tapable/tapable.d.ts","../../../node_modules/webpack/types.d.ts","../../docusaurus-types/node_modules/commander/typings/index.d.ts","../../../node_modules/joi/lib/index.d.ts","../../../node_modules/utility-types/dist/aliases-and-guards.d.ts","../../../node_modules/utility-types/dist/mapped-types.d.ts","../../../node_modules/utility-types/dist/utility-types.d.ts","../../../node_modules/utility-types/dist/functional-helpers.d.ts","../../../node_modules/utility-types/dist/index.d.ts","../../docusaurus-types/src/index.d.ts","../src/types.ts","../../docusaurus-utils/lib/posixPath.d.ts","../../docusaurus-utils/lib/constants.d.ts","../../docusaurus-utils/lib/mdxUtils.d.ts","../../docusaurus-utils/lib/normalizeUrl.d.ts","../../docusaurus-utils/lib/tags.d.ts","../../docusaurus-utils/lib/markdownParser.d.ts","../../docusaurus-utils/lib/markdownLinks.d.ts","../../docusaurus-utils/lib/escapePath.d.ts","../../docusaurus-utils/lib/slugger.d.ts","../../docusaurus-utils/lib/hashUtils.d.ts","../../../node_modules/@types/node/assert.d.ts","../../../node_modules/@types/node/globals.d.ts","../../../node_modules/@types/node/async_hooks.d.ts","../../../node_modules/@types/node/buffer.d.ts","../../../node_modules/@types/node/child_process.d.ts","../../../node_modules/@types/node/cluster.d.ts","../../../node_modules/@types/node/console.d.ts","../../../node_modules/@types/node/constants.d.ts","../../../node_modules/@types/node/crypto.d.ts","../../../node_modules/@types/node/dgram.d.ts","../../../node_modules/@types/node/dns.d.ts","../../../node_modules/@types/node/domain.d.ts","../../../node_modules/@types/node/events.d.ts","../../../node_modules/@types/node/fs.d.ts","../../../node_modules/@types/node/fs/promises.d.ts","../../../node_modules/@types/node/http.d.ts","../../../node_modules/@types/node/http2.d.ts","../../../node_modules/@types/node/https.d.ts","../../../node_modules/@types/node/inspector.d.ts","../../../node_modules/@types/node/module.d.ts","../../../node_modules/@types/node/net.d.ts","../../../node_modules/@types/node/os.d.ts","../../../node_modules/@types/node/path.d.ts","../../../node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/@types/node/process.d.ts","../../../node_modules/@types/node/punycode.d.ts","../../../node_modules/@types/node/querystring.d.ts","../../../node_modules/@types/node/readline.d.ts","../../../node_modules/@types/node/repl.d.ts","../../../node_modules/@types/node/stream.d.ts","../../../node_modules/@types/node/string_decoder.d.ts","../../../node_modules/@types/node/timers.d.ts","../../../node_modules/@types/node/tls.d.ts","../../../node_modules/@types/node/trace_events.d.ts","../../../node_modules/@types/node/tty.d.ts","../../../node_modules/@types/node/url.d.ts","../../../node_modules/@types/node/util.d.ts","../../../node_modules/@types/node/v8.d.ts","../../../node_modules/@types/node/vm.d.ts","../../../node_modules/@types/node/wasi.d.ts","../../../node_modules/@types/node/worker_threads.d.ts","../../../node_modules/@types/node/zlib.d.ts","../../../node_modules/@types/node/globals.global.d.ts","../../../node_modules/@types/node/index.d.ts","../../../node_modules/@nodelib/fs.stat/out/types/index.d.ts","../../../node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts","../../../node_modules/@nodelib/fs.stat/out/settings.d.ts","../../../node_modules/@nodelib/fs.stat/out/providers/async.d.ts","../../../node_modules/@nodelib/fs.stat/out/index.d.ts","../../../node_modules/@nodelib/fs.scandir/out/types/index.d.ts","../../../node_modules/@nodelib/fs.scandir/out/adapters/fs.d.ts","../../../node_modules/@nodelib/fs.scandir/out/settings.d.ts","../../../node_modules/@nodelib/fs.scandir/out/providers/async.d.ts","../../../node_modules/@nodelib/fs.scandir/out/index.d.ts","../../../node_modules/@nodelib/fs.walk/out/types/index.d.ts","../../../node_modules/@nodelib/fs.walk/out/settings.d.ts","../../../node_modules/@nodelib/fs.walk/out/readers/reader.d.ts","../../../node_modules/@nodelib/fs.walk/out/readers/async.d.ts","../../../node_modules/@nodelib/fs.walk/out/providers/async.d.ts","../../../node_modules/@nodelib/fs.walk/out/index.d.ts","../../../node_modules/fast-glob/out/types/index.d.ts","../../../node_modules/fast-glob/out/settings.d.ts","../../../node_modules/fast-glob/out/managers/tasks.d.ts","../../../node_modules/fast-glob/out/index.d.ts","../../../node_modules/globby/index.d.ts","../../docusaurus-utils/lib/globUtils.d.ts","../../docusaurus-utils/lib/webpackUtils.d.ts","../../docusaurus-utils/lib/index.d.ts","../src/extensionRedirects.ts","../../docusaurus-utils-validation/lib/Joi.d.ts","../../docusaurus-utils-validation/lib/JoiFrontMatter.d.ts","../../docusaurus-utils-validation/lib/validationUtils.d.ts","../../docusaurus-utils-validation/lib/validationSchemas.d.ts","../../docusaurus-utils-validation/lib/index.d.ts","../src/redirectValidation.ts","../../docusaurus-utils-common/lib/applyTrailingSlash.d.ts","../../docusaurus-utils-common/lib/index.d.ts","../../../node_modules/chalk/index.d.ts","../src/collectRedirects.ts","../../../node_modules/eta/dist/types/compile.d.ts","../../../node_modules/eta/dist/types/storage.d.ts","../../../node_modules/eta/dist/types/config.d.ts","../../../node_modules/eta/dist/types/file-handlers.d.ts","../../../node_modules/eta/dist/types/compile-string.d.ts","../../../node_modules/eta/dist/types/parse.d.ts","../../../node_modules/eta/dist/types/render.d.ts","../../../node_modules/eta/dist/types/containers.d.ts","../../../node_modules/eta/dist/types/index.d.ts","../src/templates/redirectPage.template.html.ts","../src/createRedirectPageContent.ts","../src/normalizePluginOptions.ts","../../../node_modules/@types/fs-extra/index.d.ts","../src/writeRedirectFiles.ts","../src/index.ts","../src/plugin-client-redirects.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/index.d.ts"],"fileInfos":[{"version":"6adbf5efd0e374ff5f427a4f26a5a413e9734eee5067a0e86da69aea41910b52","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","746d62152361558ea6d6115cf0da4dd10ede041d14882ede3568bce5dc4b4f1f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"abba1071bfd89e55e88a054b0c851ea3e8a494c340d0f3fab19eb18f6afb0c9e","affectsGlobalScope":true},{"version":"d8996609230d17e90484a2dd58f22668f9a05a3bfe00bfb1d6271171e54a31fb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"4378fc8122ec9d1a685b01eb66c46f62aba6b239ca7228bb6483bcf8259ee493","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"d071129cba6a5f2700be09c86c07ad2791ab67d4e5ed1eb301d6746c62745ea4","affectsGlobalScope":true},{"version":"6c55633c733c8378db65ac3da7a767c3cf2cf3057f0565a9124a16a3a2019e87","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"e8c9f4e445a489991ca1a4232667de3ac36b07ba75ea335971fbeacf2d26fe67","affectsGlobalScope":true},{"version":"10bbdc1981b8d9310ee75bfac28ee0477bb2353e8529da8cff7cb26c409cb5e8","affectsGlobalScope":true},"12f4cfe2fe60b810c3174537bc2ddb20c1067b7768643d12cb1266fd183afb75","675e702f2032766a91eeadee64f51014c64688525da99dccd8178f0c599f13a8","378df8bbbb9e3f6fca05d58f644aab538e1062eab5e778fb0b83d41125df246d","d88a479cccf787b4aa82362150fbeba5211a32dbfafa7b92ba6995ecaf9a1a89","187119ff4f9553676a884e296089e131e8cc01691c546273b1d0089c3533ce42","c24ad9be9adf28f0927e3d9d9e9cec1c677022356f241ccbbfb97bfe8fb3d1a1","0ec0998e2d085e8ea54266f547976ae152c9dd6cdb9ac4d8a520a230f5ebae84","9364c7566b0be2f7b70ff5285eb34686f83ccb01bda529b82d23b2a844653bfb","00baffbe8a2f2e4875367479489b5d43b5fc1429ecb4a4cc98cfc3009095f52a","ae9930989ed57478eb03b9b80ad3efa7a3eacdfeff0f78ecf7894c4963a64f93","3c92b6dfd43cc1c2485d9eba5ff0b74a19bb8725b692773ef1d66dac48cda4bd","3e59f00ab03c33717b3130066d4debb272da90eeded4935ff0604c2bc25a5cae","6ac6f24aff52e62c3950461aa17eab26e3a156927858e6b654baef0058b4cd1e",{"version":"0714e2046df66c0e93c3330d30dbc0565b3e8cd3ee302cf99e4ede6220e5fec8","affectsGlobalScope":true},"7d7c8ef7d48a035142c07dae60545ecc0e4af4c337742760cb09726f2f8e31db","0359682c54e487c4cab2b53b2b4d35cc8dea4d9914bc6abcdb5701f8b8e745a4","dee5d387e2e6f3015cbf91fc0c13ed6f016f9c5c1f2ad9c62602f4fd398fa83a","67f129ed8b372622ff36b8b10e39d03e09e363a5ff7821105f92f085b8d1ccba","721124f5db1f4a42da2308dfa1414d2e99055d2dfc59de7bf2e0b6ac64356c0e","0d7569149194d622212c21d5d162b0715d5a6ca764cebae7145fdbaff1e07311","cd74c8275483d3fe0d07a9b4bba28845a8a611f0aa399e961dbd40e5d46dd9ad","1bb77ef90f80a26d5db0b56e51a629bf43a67806b229aa255a4f5863483978c6","c72b982add26c5ddf410899bcafe3f47253a5d274d4b93d2ef67850d4af4545b","79468f5936bec0f62d7866f43bdc90969d996f2919b0c09618fcf8779534dced","bd0d80db12ef1aceefc4f9d3eb88517b9634fa747ae8475981da8655292feab8","55e68fb1618e3f55f7866b8c8415152159309a14b716370081ab0b7af96d876e","bf0491af2455f92282b61807be2be6e7ad7d532e47fac7b698019d3617c28ff7","5d874fb879ab8601c02549817dceb2d0a30729cb7e161625dd6f819bbff1ec0b","ee551a880882770c4f56a0964a9767c9feafe497a5be52652527d098c88d85cb","53900b299c790f5adc0d12e81a5762419d96de7c161dcec830d26617b30c085a","57dc389181eeb619a8b10299e3447cd6d9b216453af993abda5afedd6b39b455","0daf3165e72cc1ed5263a3374b98cb065f78922c76602477973ee0654b99df17","25dbbc5588c7f9a9ef359adf2ae275deef8250d919ec93db1a3a2f2e2c7ab4dd","d63db4fd77b831eb1247f1f5db90fcbfa661499bb5facfbc86944a1db149d72c","aa7611487df30b0a4265c5d473b12fd472d7585253b94e811d07727e612f1cd5","eba3847a08cea18bd0b914fa1000f5bd6b412c6c19862e442051de8d969c202d","3fedee34f24b13af4a97c4184a9e215a6f6b2dfb655dafc24970c76791b06c43","4fae0cbdbb492b0fc847ec76d0a4af44eb04028200cec088d97fca05438213f1","c7642b1c7345e546c81831fe5fa9233e15a12fa2743f6685b0d700af8292cdd0","bbe264e2fd81c101552dd353d85ac1eb8b8dbf59389fe4a4efe96ccee48d0aaf","857d6d4a53c4372a2799e733ab122d28f7b2b580fe58b80a5fe1321a733c20f7","d555cd63a3fc837840db192596273fdf52fb28092b0a33bec98e89a0334b3a4c",{"version":"dc5f6951bbf5b544349cbdef895c08dee6929818abd27d7d53c38cf1209091b3","affectsGlobalScope":true},"85d545d430795d54a8b2896f67f9aeb7bf19fd74a1469ae0627311eb72f0dfa2","a473cf45c3d9809518f8af913312139d9f4db6887dc554e0d06d0f4e52722e6b","d5afcd002167b6b03d595fb8b9630a00456b6fb9d2c5e8b6aaa30cb31bc44e2b","3d68ecf05475492f041c88395372c3a01b30351619bebcd38287ab185be7f7e4",{"version":"a97ac401f6b334e9b1f6c8ee9319d6e21cc39d2f400e909805dfb8ab5eab0576","affectsGlobalScope":true},"45ac321f2e15d268fd74a90ddaa6467dcaaff2c5b13f95b4b85831520fb7a491","7674b65ac0a3b160232d84464b3486d727415581e5b99ff4aec324500adc98a4","87f16999a5832968485f6e20dd70529399143c3cf35003485020a037f338b75f","508e1e25ca40ea6cde332d3232c826fcd82f456f45ae535d817754684f048f9e",{"version":"2866a528b2708aa272ec3eaafd3c980abb23aec1ef831cfc5eb2186b98c37ce5","affectsGlobalScope":true},{"version":"8f8f6ee2a0c94077f79439f51640a625ac7e2f5dd6866bd3b5a41705c836adfc","affectsGlobalScope":true},"ad908b2432dc4143f3439d3c625255f1050447a0232a1e9c2bffa20f37ec0097","e8d2d40a15313520a510409c8f3aeed28b79aab61af41ae65084570f9843b306","9700d148ccc0784923f66a3a7162e523172b530e8b3aa9834f53a6e893127c80","88587b5c94b0c4f5d78026e4beeb93383b3933c860d9840b55d6bf47d7b632bb","a473ecd14d9bafbd6a33105524b033237bbf1d6ce2cd81eb71cc54bec2d83d55","4e9f66d07d1687983ef1903654f4a4977563a0318046e893c5ecdb4dac25d376","0cff7901aedfe78e314f7d44088f07e2afa1b6e4f0473a4169b8456ca2fb245d","7a2a3ff87ffd4313a6a2f3b012e801dd249ee58152cedf90c8718dcd2c811fe3","69640cc2e76dad52daeb9914e6b70c5c9a5591a3a65190a2d3ea432cf0015e16","a39a4c527b7a2dc7a2661b711a534c10c76852c5ad6ae320767d3f7d2621b67d","1bb5c9857b2ee32c199dd85bc0f4c0299112485d6e5dc91428eabfdee0dbd68c",{"version":"5daba568741c8ed283d67bf370c626a91e09fdfbc6d4abe22a7f93e2cf5138b9","affectsGlobalScope":true},"7f77304372efe3c9967e5f9ea2061f1b4bf41dc3cda3c83cdd676f2e5af6b7e6","662661bbf9ccd869f3bca82d34234b2abdc95c657e2187c35352d42dddb24c2d","bec890dbc489a627439ad67330f9418d7f03aed29d1f874e5219a121da040cfa","4c4334eb5d8fae83416a361d787b55a5743916aed8af812a909898bc7333e709","6feb6f75a3e4e017f8e6e12740cf06f18eefcf829284fa310da6c7f4d44fb2eb","4fd3c4debadce3e9ab9dec3eb45f7f5e2e3d4ad65cf975a6d938d883cfb25a50","0953427f9c2498f71dd912fdd8a81b19cf6925de3e1ad67ab9a77b9a0f79bf0b","b709ff1f6d6235f5e9c8dcbce3e683ff24ec35046b232d5a281af083026018d1","7df562288f949945cf69c21cd912100c2afedeeb7cdb219085f7f4b46cb7dde4","9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5","ee6a154ecccde26b413e89c97a0b824f25b253c4c50a3c392bcb2b4c6ba9c314","d9a653f75614c4d3f63e88b7aae66390bf71a8cea02f5f7db8ca6c1a8e8c3f1a","a364b4a8a015ae377052fa4fac94204d79a69d879567f444c7ceff1b7a18482d","c5ec3b97d9db756c689cd11f4a11eaa9e6077b2768e3e9b54ff727a93c03a909","c14e9e86f18189c7d32b5dd03b4cf3f40bed68f0509dec06d75d41b82c065fe2","bdb07038733b2d74a75ba9c381dcb92774cd6f161ee125bfa921eae7d883ccc9","ad93e960a3a07dff7394bf0c8a558006a9ff2d0725ab28fc33dec227d4cb251e",{"version":"2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1","affectsGlobalScope":true},"4362a776026a354985d9f2acc54b92630d8a084948ff9592ccd8f167276c5117","46324183533e34fad2461b51174132e8e0e4b3ac1ceb5032e4952992739d1eab","d3fa0530dfb1df408f0abd76486de39def69ca47683d4a3529b2d22fce27c693","d9be977c415df16e4defe4995caeca96e637eeef9d216d0d90cdba6fc617e97e","98e0c2b48d855a844099123e8ec20fe383ecd1c5877f3895b048656befe268d0","ff53802a97b7d11ab3c4395aa052baa14cd12d2b1ed236b520a833fdd2a15003","fce9262f840a74118112caf685b725e1cc86cd2b0927311511113d90d87cc61e","d7a7cac49af2a3bfc208fe68831fbfa569864f74a7f31cc3a607f641e6c583fd","9a80e3322d08274f0e41b77923c91fe67b2c8a5134a5278c2cb60a330441554e","2460af41191009298d931c592fb6d4151beea320f1f25b73605e2211e53e4e88","2f87ea988d84d1c617afdeba9d151435473ab24cd5fc456510c8db26d8bd1581","b7336c1c536e3deaedbda956739c6250ac2d0dd171730c42cb57b10368f38a14","6fb67d664aaab2f1d1ad4613b58548aecb4b4703b9e4c5dba6b865b31bd14722","4414644199b1a047b4234965e07d189781a92b578707c79c3933918d67cd9d85","04a4b38c6a1682059eac00e7d0948d99c46642b57003d61d0fe9ccc9df442887","f12ea658b060da1752c65ae4f1e4c248587f6cd4cb4acabbf79a110b6b02ff75","011b2857871a878d5eae463bedc4b3dd14755dc3a67d5d10f8fbb7823d119294","e175549fe57dbff5cd68c1a5ccf33717584d7db9afb8ec216fd2c0daa3b06931","ea68c312e1eb9b48f7064a8dda348594769ba8f9c8596315827c559734a60205","6ddb5fb4476ca702ecff9e5ff0295cde6ce138d71f817da65e118a2a3c534106","6dfff2e65f10158f5a868e642a2e74d2d1bd76f15291552f389f2b8c829a9a86","41c78f187749098f9b8e8982839a010b6bf00dacc654d759b9c169127bcda034","4b72b4c3e5b21e06453e213fca18d0b2464199ccd5091da9eb2ba78fcdb91057","832962980c7b16acad0eab132faa982f8d241218b6ecd4a1443bfbafb5da18dd","f2ad082ce6503d45f4f703e6853d7e3ca2e6b158dcd7be78bf452c39203d49bb","49de8feed534ff6ab66fbfc2bf1ea0a0449338a2dce2ed51bf9f29fb4da239a3","889859c907d8388cfe92d4bdfe5b5ff0885a41e6e4568691230e21757f7673c9","df8e0b622962e734e62c8e98423622900d62abd0a9fadc9a9c2bd095bf34952a","587d29bdf3f945aef9e94f92cdb8fa90b0ecbce7e6dc76411875ed5b436cd1be","faf6642e20b9b95375af851dee261aa115bc1204a41dcca7740cbdde4b9af52e","8387c74026355f5df1eec752beaf0f88c87a3a23f8945e3728984a08fa40d106","700c2f83a83482242336bf0033edbd961105577f16b9cf549333159fc719add2","63c9b50b55f320e8da81290acd27de8e1dab92e13b3ec7f24b80fde9dd80b795","e2d8df8b27288ae207cbdcef0c6a698824b974f53035ed729ddef26cd7692e75","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","0b981c80a204cb415e8c1ef198e13b09c6a44cbbd8a9ba097f708c150f42bcd5","a3cf09a8ce34726b0557b3e51135a6768b464e86b7190355e42f10ba368e9786","dcd04eabb6c23406dc589f688c7a83d25a8aa0c93ee34c0be1114113c32792d6","0a21f90e2ffaf26b305183fd2029a7dd512bb3189a9d6842ba764782e609429e","7738be042bbc5acbe24a3d06b11c0e7656b43e5185c3af58690419946c6248d7","bd868c7a5868f2680d332b85283be6be45edb766a95c4b8034aff7c741ab1aad","5ec0c5db09dfb4f1cd140417dc86fed025bd757d63c11fe2c4148ec12fd20111","810c09c0ee1daf5a4472e28419ccb3f3f1c837c2b8c663b488c8c56a2af40c39","2db6353e2fdcbd2842b5b0a36d11e11ffbff703552e19481a55a63155e14c6be","74175ef96c3d3cb5e7bcaf0387ca4cc3de9f1bf68b42a082d8be5e79178c2c7e","37723b12b6a526579c9a467ab70a9414fc30994e24bd4b9dae41148ed3e112a1","cb36f4facbc37ab565c40bb163b9dc44b7e315684edf2db624aecfda10a3081f","df9c209354a3ee3a46d611009393d3db30509d662c352ac7391f5d450d00edd6","ed19da84b7dbf00952ad0b98ce5c194f1903bcf7c94d8103e8e0d63b271543ae","44188647280474d7f2f1c06f1f5a32be7e682f1e29b857983eb76550009051ba","c16e15a7bbbb323cdf9df7a6b05a96b474831768886e0c85f5e0df3275249923","09ed869dd64962b7b5e4dc8dee93f14a92868fddcde0bba29ab2c021e9cce227"],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"declarationMap":false,"esModuleInterop":true,"importHelpers":true,"jsx":2,"module":1,"noEmitHelpers":true,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noImplicitThis":true,"noUnusedLocals":false,"noUnusedParameters":false,"outDir":"./","rootDir":"../src","skipLibCheck":true,"strict":true,"strictNullChecks":true,"strictPropertyInitialization":true,"target":6,"tsBuildInfoFile":"./.tsbuildinfo"},"fileIdsList":[[135,136],[136,137,138,139],[130,136,138],[135,137],[100,130],[100,130,131],[131,132,133,134],[131,133],[132],[116,130,140,141,142,145],[141,142,144],[99,130,140,141,142,143],[142],[140,141],[130,140],[100,182],[47,49,50,51,52,53,54,55,56,57,58,59],[47,48,50,51,52,53,54,55,56,57,58,59],[48,49,50,51,52,53,54,55,56,57,58,59],[47,48,49,51,52,53,54,55,56,57,58,59],[47,48,49,50,52,53,54,55,56,57,58,59],[47,48,49,50,51,53,54,55,56,57,58,59],[47,48,49,50,51,52,54,55,56,57,58,59],[47,48,49,50,51,52,53,55,56,57,58,59],[47,48,49,50,51,52,53,54,56,57,58,59],[47,48,49,50,51,52,53,54,55,57,58,59],[47,48,49,50,51,52,53,54,55,56,58,59],[47,48,49,50,51,52,53,54,55,56,57,59],[47,48,49,50,51,52,53,54,55,56,57,58],[99,100,107,116],[91,99,107],[123],[95,100,108],[116],[97,99,107],[99],[99,101,116,122],[100],[107,116,122],[99,100,102,107,116,119,122],[102,116,119,122],[87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129],[122],[97,99,116],[89],[121],[114,123,125],[107],[113],[99,101,116,122,125],[168],[168,169],[166,167],[166,168],[166,168,169,170,171,172,173],[166,168,169],[130,147,148,149],[147,148],[147],[130,146],[150],[61,64],[64],[61,62,63],[70,71,72,73],[70],[71],[60,62,64,65,66,102,107,119],[46,59,76,155,161,163,164],[46,59,174,175],[46,76,154],[46,75,76,154,165,177,179],[46,76,154,160],[76],[46,76,160],[46],[46,75],[46,59,76,109,154,176,178],[67,68,69,74,113],[75],[162],[69],[156],[156,157,158,159],[151],[75,77,78,79,80,81,82,83,84,85,86,152,153],[67]],"referencedMap":[[137,1],[140,2],[139,3],[138,4],[136,5],[132,6],[135,7],[134,8],[133,9],[131,5],[146,10],[145,11],[144,12],[143,13],[142,14],[141,15],[178,16],[48,17],[49,18],[47,19],[50,20],[51,21],[52,22],[53,23],[54,24],[55,25],[56,26],[57,27],[58,28],[59,29],[91,30],[92,31],[93,32],[94,33],[95,34],[96,35],[98,36],[99,36],[100,37],[101,38],[102,39],[103,40],[104,41],[130,42],[105,36],[106,43],[107,44],[110,45],[111,46],[114,36],[115,47],[116,36],[119,48],[121,48],[122,49],[124,34],[127,50],[128,34],[170,51],[166,52],[168,53],[173,53],[169,54],[174,55],[171,51],[172,56],[150,57],[149,58],[148,59],[147,60],[151,61],[62,62],[65,63],[64,64],[74,65],[71,66],[72,67],[67,68],[165,69],[176,70],[155,71],[180,72],[177,73],[181,74],[161,75],[175,76],[76,77],[179,78],[75,79],[162,80],[163,81],[156,82],[157,83],[160,84],[159,83],[158,83],[152,85],[154,86],[153,87]],"exportedModulesMap":[[137,1],[140,2],[139,3],[138,4],[136,5],[132,6],[135,7],[134,8],[133,9],[131,5],[146,10],[145,11],[144,12],[143,13],[142,14],[141,15],[178,16],[48,17],[49,18],[47,19],[50,20],[51,21],[52,22],[53,23],[54,24],[55,25],[56,26],[57,27],[58,28],[59,29],[91,30],[92,31],[93,32],[94,33],[95,34],[96,35],[98,36],[99,36],[100,37],[101,38],[102,39],[103,40],[104,41],[130,42],[105,36],[106,43],[107,44],[110,45],[111,46],[114,36],[115,47],[116,36],[119,48],[121,48],[122,49],[124,34],[127,50],[128,34],[170,51],[166,52],[168,53],[173,53],[169,54],[174,55],[171,51],[172,56],[150,57],[149,58],[148,59],[147,60],[151,61],[62,62],[65,63],[64,64],[74,65],[71,66],[72,67],[67,68],[165,69],[176,70],[155,71],[180,72],[177,73],[181,74],[161,75],[175,76],[76,77],[179,78],[75,79],[162,80],[163,81],[156,82],[157,83],[160,84],[159,83],[158,83],[152,85],[154,86],[153,87]],"semanticDiagnosticsPerFile":[137,140,139,138,136,132,135,134,133,131,146,145,144,143,142,141,60,178,61,48,49,47,50,51,52,53,54,55,56,57,58,59,87,89,90,91,92,93,94,95,96,97,98,99,100,101,88,129,102,103,104,130,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,63,164,170,166,168,173,169,174,171,172,167,150,149,148,147,151,69,62,65,64,66,46,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,44,41,42,43,1,9,45,70,73,74,71,72,67,165,176,155,180,177,181,161,175,76,179,68,75,162,163,156,157,160,159,158,78,84,152,86,154,83,82,79,80,77,85,81,153]},"version":"4.5.2"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`collectRedirects should throw if plugin option redirects contain invalid to paths 1`] = `
|
|
4
|
-
"You are trying to create client-side redirections to paths that do not exist:
|
|
5
|
-
- /this/path/does/not/exist2
|
|
6
|
-
- /this/path/does/not/exist2
|
|
7
|
-
|
|
8
|
-
Valid paths you can redirect to:
|
|
9
|
-
- /
|
|
10
|
-
- /someExistingPath
|
|
11
|
-
- /anotherExistingPath
|
|
12
|
-
"
|
|
13
|
-
`;
|
|
14
|
-
|
|
15
|
-
exports[`collectRedirects should throw if redirect creator creates array of array redirect 1`] = `
|
|
16
|
-
"Some created redirects are invalid:
|
|
17
|
-
- {\\"from\\":[\\"/fromPath\\"],\\"to\\":\\"/\\"} => Validation error: \\"from\\" must be a string
|
|
18
|
-
"
|
|
19
|
-
`;
|
|
20
|
-
|
|
21
|
-
exports[`collectRedirects should throw if redirect creator creates invalid redirects 1`] = `
|
|
22
|
-
"Some created redirects are invalid:
|
|
23
|
-
- {\\"from\\":\\"https://google.com/\\",\\"to\\":\\"/\\"} => Validation error: \\"from\\" is not a valid pathname. Pathname should start with slash and not contain any domain or query string.
|
|
24
|
-
- {\\"from\\":\\"//abc\\",\\"to\\":\\"/\\"} => Validation error: \\"from\\" is not a valid pathname. Pathname should start with slash and not contain any domain or query string.
|
|
25
|
-
- {\\"from\\":\\"/def?queryString=toto\\",\\"to\\":\\"/\\"} => Validation error: \\"from\\" is not a valid pathname. Pathname should start with slash and not contain any domain or query string.
|
|
26
|
-
"
|
|
27
|
-
`;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`createRedirectPageContent should encode uri special chars 1`] = `
|
|
4
|
-
"<!DOCTYPE html>
|
|
5
|
-
<html>
|
|
6
|
-
<head>
|
|
7
|
-
<meta charset=\\"UTF-8\\">
|
|
8
|
-
<meta http-equiv=\\"refresh\\" content=\\"0; url=https://docusaurus.io/gr/%CF%83%CE%B5%CE%BB%CE%B9%CE%B4%CE%B1%CF%82/\\">
|
|
9
|
-
<link rel=\\"canonical\\" href=\\"https://docusaurus.io/gr/%CF%83%CE%B5%CE%BB%CE%B9%CE%B4%CE%B1%CF%82/\\" />
|
|
10
|
-
</head>
|
|
11
|
-
<script>
|
|
12
|
-
window.location.href = 'https://docusaurus.io/gr/%CF%83%CE%B5%CE%BB%CE%B9%CE%B4%CE%B1%CF%82/';
|
|
13
|
-
</script>
|
|
14
|
-
</html>"
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
exports[`createRedirectPageContent should match snapshot 1`] = `
|
|
18
|
-
"<!DOCTYPE html>
|
|
19
|
-
<html>
|
|
20
|
-
<head>
|
|
21
|
-
<meta charset=\\"UTF-8\\">
|
|
22
|
-
<meta http-equiv=\\"refresh\\" content=\\"0; url=https://docusaurus.io/\\">
|
|
23
|
-
<link rel=\\"canonical\\" href=\\"https://docusaurus.io/\\" />
|
|
24
|
-
</head>
|
|
25
|
-
<script>
|
|
26
|
-
window.location.href = 'https://docusaurus.io/';
|
|
27
|
-
</script>
|
|
28
|
-
</html>"
|
|
29
|
-
`;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`normalizePluginOptions should reject bad createRedirects user inputs 1`] = `
|
|
4
|
-
"Invalid @docusaurus/plugin-client-redirects options: \\"createRedirects\\" must be of type function
|
|
5
|
-
{
|
|
6
|
-
\\"createRedirects\\": [
|
|
7
|
-
\\"bad\\",
|
|
8
|
-
\\"value\\"
|
|
9
|
-
]
|
|
10
|
-
}"
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
|
-
exports[`normalizePluginOptions should reject bad fromExtensions user inputs 1`] = `
|
|
14
|
-
"Invalid @docusaurus/plugin-client-redirects options: \\"fromExtensions[0]\\" contains an invalid value
|
|
15
|
-
{
|
|
16
|
-
\\"fromExtensions\\": [
|
|
17
|
-
null,
|
|
18
|
-
null,
|
|
19
|
-
123,
|
|
20
|
-
true
|
|
21
|
-
]
|
|
22
|
-
}"
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
exports[`normalizePluginOptions should reject bad toExtensions user inputs 1`] = `
|
|
26
|
-
"Invalid @docusaurus/plugin-client-redirects options: \\"toExtensions[0]\\" contains an invalid value
|
|
27
|
-
{
|
|
28
|
-
\\"toExtensions\\": [
|
|
29
|
-
null,
|
|
30
|
-
null,
|
|
31
|
-
123,
|
|
32
|
-
true
|
|
33
|
-
]
|
|
34
|
-
}"
|
|
35
|
-
`;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`validateRedirect throw for bad redirects 1`] = `"{\\"from\\":\\"https://fb.com/fromSomePath\\",\\"to\\":\\"/toSomePath\\"} => Validation error: \\"from\\" is not a valid pathname. Pathname should start with slash and not contain any domain or query string."`;
|
|
4
|
-
|
|
5
|
-
exports[`validateRedirect throw for bad redirects 2`] = `"{\\"from\\":\\"/fromSomePath\\",\\"to\\":\\"https://fb.com/toSomePath\\"} => Validation error: \\"to\\" is not a valid pathname. Pathname should start with slash and not contain any domain or query string."`;
|
|
6
|
-
|
|
7
|
-
exports[`validateRedirect throw for bad redirects 3`] = `"{\\"from\\":\\"/fromSomePath\\",\\"to\\":\\"/toSomePath?queryString=xyz\\"} => Validation error: \\"to\\" is not a valid pathname. Pathname should start with slash and not contain any domain or query string."`;
|
|
8
|
-
|
|
9
|
-
exports[`validateRedirect throw for bad redirects 4`] = `"{\\"from\\":null,\\"to\\":\\"/toSomePath?queryString=xyz\\"} => Validation error: \\"from\\" must be a string"`;
|
|
10
|
-
|
|
11
|
-
exports[`validateRedirect throw for bad redirects 5`] = `"{\\"from\\":[\\"heyho\\"],\\"to\\":\\"/toSomePath?queryString=xyz\\"} => Validation error: \\"from\\" must be a string"`;
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`toRedirectFilesMetadata should create appropriate metadata for empty baseUrl: fileContent baseUrl=empty 1`] = `
|
|
4
|
-
Array [
|
|
5
|
-
"<!DOCTYPE html>
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<meta charset=\\"UTF-8\\">
|
|
9
|
-
<meta http-equiv=\\"refresh\\" content=\\"0; url=/abc\\">
|
|
10
|
-
<link rel=\\"canonical\\" href=\\"/abc\\" />
|
|
11
|
-
</head>
|
|
12
|
-
<script>
|
|
13
|
-
window.location.href = '/abc';
|
|
14
|
-
</script>
|
|
15
|
-
</html>",
|
|
16
|
-
]
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
exports[`toRedirectFilesMetadata should create appropriate metadata for root baseUrl: fileContent baseUrl=/ 1`] = `
|
|
20
|
-
Array [
|
|
21
|
-
"<!DOCTYPE html>
|
|
22
|
-
<html>
|
|
23
|
-
<head>
|
|
24
|
-
<meta charset=\\"UTF-8\\">
|
|
25
|
-
<meta http-equiv=\\"refresh\\" content=\\"0; url=/abc\\">
|
|
26
|
-
<link rel=\\"canonical\\" href=\\"/abc\\" />
|
|
27
|
-
</head>
|
|
28
|
-
<script>
|
|
29
|
-
window.location.href = '/abc';
|
|
30
|
-
</script>
|
|
31
|
-
</html>",
|
|
32
|
-
]
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
exports[`toRedirectFilesMetadata should create appropriate metadata trailingSlash=false: fileContent 1`] = `
|
|
36
|
-
Array [
|
|
37
|
-
"<!DOCTYPE html>
|
|
38
|
-
<html>
|
|
39
|
-
<head>
|
|
40
|
-
<meta charset=\\"UTF-8\\">
|
|
41
|
-
<meta http-equiv=\\"refresh\\" content=\\"0; url=https://docusaurus.io/abc\\">
|
|
42
|
-
<link rel=\\"canonical\\" href=\\"https://docusaurus.io/abc\\" />
|
|
43
|
-
</head>
|
|
44
|
-
<script>
|
|
45
|
-
window.location.href = 'https://docusaurus.io/abc';
|
|
46
|
-
</script>
|
|
47
|
-
</html>",
|
|
48
|
-
"<!DOCTYPE html>
|
|
49
|
-
<html>
|
|
50
|
-
<head>
|
|
51
|
-
<meta charset=\\"UTF-8\\">
|
|
52
|
-
<meta http-equiv=\\"refresh\\" content=\\"0; url=https://docusaurus.io/def.html\\">
|
|
53
|
-
<link rel=\\"canonical\\" href=\\"https://docusaurus.io/def.html\\" />
|
|
54
|
-
</head>
|
|
55
|
-
<script>
|
|
56
|
-
window.location.href = 'https://docusaurus.io/def.html';
|
|
57
|
-
</script>
|
|
58
|
-
</html>",
|
|
59
|
-
"<!DOCTYPE html>
|
|
60
|
-
<html>
|
|
61
|
-
<head>
|
|
62
|
-
<meta charset=\\"UTF-8\\">
|
|
63
|
-
<meta http-equiv=\\"refresh\\" content=\\"0; url=https://docusaurus.io/\\">
|
|
64
|
-
<link rel=\\"canonical\\" href=\\"https://docusaurus.io/\\" />
|
|
65
|
-
</head>
|
|
66
|
-
<script>
|
|
67
|
-
window.location.href = 'https://docusaurus.io/';
|
|
68
|
-
</script>
|
|
69
|
-
</html>",
|
|
70
|
-
]
|
|
71
|
-
`;
|
|
72
|
-
|
|
73
|
-
exports[`toRedirectFilesMetadata should create appropriate metadata trailingSlash=true: fileContent 1`] = `
|
|
74
|
-
Array [
|
|
75
|
-
"<!DOCTYPE html>
|
|
76
|
-
<html>
|
|
77
|
-
<head>
|
|
78
|
-
<meta charset=\\"UTF-8\\">
|
|
79
|
-
<meta http-equiv=\\"refresh\\" content=\\"0; url=https://docusaurus.io/abc\\">
|
|
80
|
-
<link rel=\\"canonical\\" href=\\"https://docusaurus.io/abc\\" />
|
|
81
|
-
</head>
|
|
82
|
-
<script>
|
|
83
|
-
window.location.href = 'https://docusaurus.io/abc';
|
|
84
|
-
</script>
|
|
85
|
-
</html>",
|
|
86
|
-
"<!DOCTYPE html>
|
|
87
|
-
<html>
|
|
88
|
-
<head>
|
|
89
|
-
<meta charset=\\"UTF-8\\">
|
|
90
|
-
<meta http-equiv=\\"refresh\\" content=\\"0; url=https://docusaurus.io/def.html\\">
|
|
91
|
-
<link rel=\\"canonical\\" href=\\"https://docusaurus.io/def.html\\" />
|
|
92
|
-
</head>
|
|
93
|
-
<script>
|
|
94
|
-
window.location.href = 'https://docusaurus.io/def.html';
|
|
95
|
-
</script>
|
|
96
|
-
</html>",
|
|
97
|
-
"<!DOCTYPE html>
|
|
98
|
-
<html>
|
|
99
|
-
<head>
|
|
100
|
-
<meta charset=\\"UTF-8\\">
|
|
101
|
-
<meta http-equiv=\\"refresh\\" content=\\"0; url=https://docusaurus.io/\\">
|
|
102
|
-
<link rel=\\"canonical\\" href=\\"https://docusaurus.io/\\" />
|
|
103
|
-
</head>
|
|
104
|
-
<script>
|
|
105
|
-
window.location.href = 'https://docusaurus.io/';
|
|
106
|
-
</script>
|
|
107
|
-
</html>",
|
|
108
|
-
]
|
|
109
|
-
`;
|
|
110
|
-
|
|
111
|
-
exports[`toRedirectFilesMetadata should create appropriate metadata trailingSlash=undefined: fileContent 1`] = `
|
|
112
|
-
Array [
|
|
113
|
-
"<!DOCTYPE html>
|
|
114
|
-
<html>
|
|
115
|
-
<head>
|
|
116
|
-
<meta charset=\\"UTF-8\\">
|
|
117
|
-
<meta http-equiv=\\"refresh\\" content=\\"0; url=https://docusaurus.io/abc\\">
|
|
118
|
-
<link rel=\\"canonical\\" href=\\"https://docusaurus.io/abc\\" />
|
|
119
|
-
</head>
|
|
120
|
-
<script>
|
|
121
|
-
window.location.href = 'https://docusaurus.io/abc';
|
|
122
|
-
</script>
|
|
123
|
-
</html>",
|
|
124
|
-
"<!DOCTYPE html>
|
|
125
|
-
<html>
|
|
126
|
-
<head>
|
|
127
|
-
<meta charset=\\"UTF-8\\">
|
|
128
|
-
<meta http-equiv=\\"refresh\\" content=\\"0; url=https://docusaurus.io/def.html\\">
|
|
129
|
-
<link rel=\\"canonical\\" href=\\"https://docusaurus.io/def.html\\" />
|
|
130
|
-
</head>
|
|
131
|
-
<script>
|
|
132
|
-
window.location.href = 'https://docusaurus.io/def.html';
|
|
133
|
-
</script>
|
|
134
|
-
</html>",
|
|
135
|
-
"<!DOCTYPE html>
|
|
136
|
-
<html>
|
|
137
|
-
<head>
|
|
138
|
-
<meta charset=\\"UTF-8\\">
|
|
139
|
-
<meta http-equiv=\\"refresh\\" content=\\"0; url=https://docusaurus.io/\\">
|
|
140
|
-
<link rel=\\"canonical\\" href=\\"https://docusaurus.io/\\" />
|
|
141
|
-
</head>
|
|
142
|
-
<script>
|
|
143
|
-
window.location.href = 'https://docusaurus.io/';
|
|
144
|
-
</script>
|
|
145
|
-
</html>",
|
|
146
|
-
]
|
|
147
|
-
`;
|
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import {PluginContext, UserPluginOptions} from '../types';
|
|
9
|
-
import collectRedirects from '../collectRedirects';
|
|
10
|
-
import normalizePluginOptions from '../normalizePluginOptions';
|
|
11
|
-
import {removeTrailingSlash} from '@docusaurus/utils';
|
|
12
|
-
|
|
13
|
-
function createTestPluginContext(
|
|
14
|
-
options?: UserPluginOptions,
|
|
15
|
-
relativeRoutesPaths: string[] = [],
|
|
16
|
-
): PluginContext {
|
|
17
|
-
return {
|
|
18
|
-
outDir: '/tmp',
|
|
19
|
-
baseUrl: 'https://docusaurus.io',
|
|
20
|
-
relativeRoutesPaths,
|
|
21
|
-
options: normalizePluginOptions(options),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
describe('collectRedirects', () => {
|
|
26
|
-
test('should collect no redirect for undefined config', () => {
|
|
27
|
-
expect(
|
|
28
|
-
collectRedirects(
|
|
29
|
-
createTestPluginContext(undefined, ['/', '/path']),
|
|
30
|
-
undefined,
|
|
31
|
-
),
|
|
32
|
-
).toEqual([]);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test('should collect no redirect for empty config', () => {
|
|
36
|
-
expect(collectRedirects(createTestPluginContext({}), undefined)).toEqual(
|
|
37
|
-
[],
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test('should collect redirects to html/exe extension', () => {
|
|
42
|
-
expect(
|
|
43
|
-
collectRedirects(
|
|
44
|
-
createTestPluginContext(
|
|
45
|
-
{
|
|
46
|
-
fromExtensions: ['html', 'exe'],
|
|
47
|
-
},
|
|
48
|
-
['/', '/somePath', '/otherPath.html'],
|
|
49
|
-
),
|
|
50
|
-
undefined,
|
|
51
|
-
),
|
|
52
|
-
).toEqual([
|
|
53
|
-
{
|
|
54
|
-
from: '/somePath.html',
|
|
55
|
-
to: '/somePath',
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
from: '/somePath.exe',
|
|
59
|
-
to: '/somePath',
|
|
60
|
-
},
|
|
61
|
-
]);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test('should collect redirects to html/exe extension', () => {
|
|
65
|
-
expect(
|
|
66
|
-
collectRedirects(
|
|
67
|
-
createTestPluginContext(
|
|
68
|
-
{
|
|
69
|
-
toExtensions: ['html', 'exe'],
|
|
70
|
-
},
|
|
71
|
-
['/', '/somePath', '/otherPath.html'],
|
|
72
|
-
),
|
|
73
|
-
undefined,
|
|
74
|
-
),
|
|
75
|
-
).toEqual([
|
|
76
|
-
{
|
|
77
|
-
from: '/otherPath',
|
|
78
|
-
to: '/otherPath.html',
|
|
79
|
-
},
|
|
80
|
-
]);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test('should collect redirects from plugin option redirects', () => {
|
|
84
|
-
expect(
|
|
85
|
-
collectRedirects(
|
|
86
|
-
createTestPluginContext(
|
|
87
|
-
{
|
|
88
|
-
redirects: [
|
|
89
|
-
{
|
|
90
|
-
from: '/someLegacyPath',
|
|
91
|
-
to: '/somePath',
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
from: ['/someLegacyPathArray1', '/someLegacyPathArray2'],
|
|
95
|
-
to: '/',
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
},
|
|
99
|
-
['/', '/somePath'],
|
|
100
|
-
),
|
|
101
|
-
undefined,
|
|
102
|
-
),
|
|
103
|
-
).toEqual([
|
|
104
|
-
{
|
|
105
|
-
from: '/someLegacyPath',
|
|
106
|
-
to: '/somePath',
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
from: '/someLegacyPathArray1',
|
|
110
|
-
to: '/',
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
from: '/someLegacyPathArray2',
|
|
114
|
-
to: '/',
|
|
115
|
-
},
|
|
116
|
-
]);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
test('should collect redirects from plugin option redirects with trailingSlash=true', () => {
|
|
120
|
-
expect(
|
|
121
|
-
collectRedirects(
|
|
122
|
-
createTestPluginContext(
|
|
123
|
-
{
|
|
124
|
-
redirects: [
|
|
125
|
-
{
|
|
126
|
-
from: '/someLegacyPath',
|
|
127
|
-
to: '/somePath',
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
from: ['/someLegacyPathArray1', '/someLegacyPathArray2'],
|
|
131
|
-
to: '/',
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
},
|
|
135
|
-
['/', '/somePath/'],
|
|
136
|
-
),
|
|
137
|
-
true,
|
|
138
|
-
),
|
|
139
|
-
).toEqual([
|
|
140
|
-
{
|
|
141
|
-
from: '/someLegacyPath',
|
|
142
|
-
to: '/somePath/',
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
from: '/someLegacyPathArray1',
|
|
146
|
-
to: '/',
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
from: '/someLegacyPathArray2',
|
|
150
|
-
to: '/',
|
|
151
|
-
},
|
|
152
|
-
]);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
test('should collect redirects from plugin option redirects with trailingSlash=false', () => {
|
|
156
|
-
expect(
|
|
157
|
-
collectRedirects(
|
|
158
|
-
createTestPluginContext(
|
|
159
|
-
{
|
|
160
|
-
redirects: [
|
|
161
|
-
{
|
|
162
|
-
from: '/someLegacyPath',
|
|
163
|
-
to: '/somePath/',
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
from: ['/someLegacyPathArray1', '/someLegacyPathArray2'],
|
|
167
|
-
to: '/',
|
|
168
|
-
},
|
|
169
|
-
],
|
|
170
|
-
},
|
|
171
|
-
['/', '/somePath'],
|
|
172
|
-
),
|
|
173
|
-
false,
|
|
174
|
-
),
|
|
175
|
-
).toEqual([
|
|
176
|
-
{
|
|
177
|
-
from: '/someLegacyPath',
|
|
178
|
-
to: '/somePath',
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
from: '/someLegacyPathArray1',
|
|
182
|
-
to: '/',
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
from: '/someLegacyPathArray2',
|
|
186
|
-
to: '/',
|
|
187
|
-
},
|
|
188
|
-
]);
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
test('should throw if plugin option redirects contain invalid to paths', () => {
|
|
192
|
-
expect(() =>
|
|
193
|
-
collectRedirects(
|
|
194
|
-
createTestPluginContext(
|
|
195
|
-
{
|
|
196
|
-
redirects: [
|
|
197
|
-
{
|
|
198
|
-
from: '/someLegacyPath',
|
|
199
|
-
to: '/',
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
from: '/someLegacyPath',
|
|
203
|
-
to: '/this/path/does/not/exist2',
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
from: '/someLegacyPath',
|
|
207
|
-
to: '/this/path/does/not/exist2',
|
|
208
|
-
},
|
|
209
|
-
],
|
|
210
|
-
},
|
|
211
|
-
['/', '/someExistingPath', '/anotherExistingPath'],
|
|
212
|
-
),
|
|
213
|
-
undefined,
|
|
214
|
-
),
|
|
215
|
-
).toThrowErrorMatchingSnapshot();
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
test('should collect redirects with custom redirect creator', () => {
|
|
219
|
-
expect(
|
|
220
|
-
collectRedirects(
|
|
221
|
-
createTestPluginContext(
|
|
222
|
-
{
|
|
223
|
-
createRedirects: (routePath) => [
|
|
224
|
-
`${removeTrailingSlash(routePath)}/some/path/suffix1`,
|
|
225
|
-
`${removeTrailingSlash(routePath)}/some/other/path/suffix2`,
|
|
226
|
-
],
|
|
227
|
-
},
|
|
228
|
-
['/', '/testpath', '/otherPath.html'],
|
|
229
|
-
),
|
|
230
|
-
undefined,
|
|
231
|
-
),
|
|
232
|
-
).toEqual([
|
|
233
|
-
{
|
|
234
|
-
from: '/some/path/suffix1',
|
|
235
|
-
to: '/',
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
from: '/some/other/path/suffix2',
|
|
239
|
-
to: '/',
|
|
240
|
-
},
|
|
241
|
-
|
|
242
|
-
{
|
|
243
|
-
from: '/testpath/some/path/suffix1',
|
|
244
|
-
to: '/testpath',
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
from: '/testpath/some/other/path/suffix2',
|
|
248
|
-
to: '/testpath',
|
|
249
|
-
},
|
|
250
|
-
|
|
251
|
-
{
|
|
252
|
-
from: '/otherPath.html/some/path/suffix1',
|
|
253
|
-
to: '/otherPath.html',
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
from: '/otherPath.html/some/other/path/suffix2',
|
|
257
|
-
to: '/otherPath.html',
|
|
258
|
-
},
|
|
259
|
-
]);
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
test('should throw if redirect creator creates invalid redirects', () => {
|
|
263
|
-
expect(() =>
|
|
264
|
-
collectRedirects(
|
|
265
|
-
createTestPluginContext(
|
|
266
|
-
{
|
|
267
|
-
createRedirects: (routePath) => {
|
|
268
|
-
if (routePath === '/') {
|
|
269
|
-
return [
|
|
270
|
-
`https://google.com/`,
|
|
271
|
-
`//abc`,
|
|
272
|
-
`/def?queryString=toto`,
|
|
273
|
-
];
|
|
274
|
-
}
|
|
275
|
-
return undefined;
|
|
276
|
-
},
|
|
277
|
-
},
|
|
278
|
-
['/'],
|
|
279
|
-
),
|
|
280
|
-
undefined,
|
|
281
|
-
),
|
|
282
|
-
).toThrowErrorMatchingSnapshot();
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
test('should throw if redirect creator creates array of array redirect', () => {
|
|
286
|
-
expect(() =>
|
|
287
|
-
collectRedirects(
|
|
288
|
-
createTestPluginContext(
|
|
289
|
-
{
|
|
290
|
-
createRedirects: (routePath) => {
|
|
291
|
-
if (routePath === '/') {
|
|
292
|
-
return [[`/fromPath`]] as unknown as string;
|
|
293
|
-
}
|
|
294
|
-
return undefined;
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
['/'],
|
|
298
|
-
),
|
|
299
|
-
undefined,
|
|
300
|
-
),
|
|
301
|
-
).toThrowErrorMatchingSnapshot();
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
test('should filter unwanted redirects', () => {
|
|
305
|
-
expect(
|
|
306
|
-
collectRedirects(
|
|
307
|
-
createTestPluginContext(
|
|
308
|
-
{
|
|
309
|
-
fromExtensions: ['html', 'exe'],
|
|
310
|
-
toExtensions: ['html', 'exe'],
|
|
311
|
-
},
|
|
312
|
-
[
|
|
313
|
-
'/',
|
|
314
|
-
'/somePath',
|
|
315
|
-
'/somePath.html',
|
|
316
|
-
'/somePath.exe',
|
|
317
|
-
'/fromShouldWork.html',
|
|
318
|
-
'/toShouldWork',
|
|
319
|
-
],
|
|
320
|
-
),
|
|
321
|
-
undefined,
|
|
322
|
-
),
|
|
323
|
-
).toEqual([
|
|
324
|
-
{
|
|
325
|
-
from: '/toShouldWork.html',
|
|
326
|
-
to: '/toShouldWork',
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
from: '/toShouldWork.exe',
|
|
330
|
-
to: '/toShouldWork',
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
from: '/fromShouldWork',
|
|
334
|
-
to: '/fromShouldWork.html',
|
|
335
|
-
},
|
|
336
|
-
]);
|
|
337
|
-
});
|
|
338
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import createRedirectPageContent from '../createRedirectPageContent';
|
|
9
|
-
|
|
10
|
-
describe('createRedirectPageContent', () => {
|
|
11
|
-
test('should match snapshot', () => {
|
|
12
|
-
expect(
|
|
13
|
-
createRedirectPageContent({toUrl: 'https://docusaurus.io/'}),
|
|
14
|
-
).toMatchSnapshot();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test('should encode uri special chars', () => {
|
|
18
|
-
const result = createRedirectPageContent({
|
|
19
|
-
toUrl: 'https://docusaurus.io/gr/σελιδας/',
|
|
20
|
-
});
|
|
21
|
-
expect(result).toContain(
|
|
22
|
-
'https://docusaurus.io/gr/%CF%83%CE%B5%CE%BB%CE%B9%CE%B4%CE%B1%CF%82/',
|
|
23
|
-
);
|
|
24
|
-
expect(result).toMatchSnapshot();
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
createFromExtensionsRedirects,
|
|
10
|
-
createToExtensionsRedirects,
|
|
11
|
-
} from '../extensionRedirects';
|
|
12
|
-
|
|
13
|
-
describe('createToExtensionsRedirects', () => {
|
|
14
|
-
test('should reject empty extensions', () => {
|
|
15
|
-
expect(() => {
|
|
16
|
-
createToExtensionsRedirects(['/'], ['.html']);
|
|
17
|
-
}).toThrowErrorMatchingInlineSnapshot(`
|
|
18
|
-
"Extension \\".html\\" contains a \\".\\" (dot) which is not allowed.
|
|
19
|
-
If the redirect extension system is not good enough for your usecase, you can create redirects yourself with the \\"createRedirects\\" plugin option."
|
|
20
|
-
`);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('should reject extensions with .', () => {
|
|
24
|
-
expect(() => {
|
|
25
|
-
createToExtensionsRedirects(['/'], ['.html']);
|
|
26
|
-
}).toThrowErrorMatchingInlineSnapshot(`
|
|
27
|
-
"Extension \\".html\\" contains a \\".\\" (dot) which is not allowed.
|
|
28
|
-
If the redirect extension system is not good enough for your usecase, you can create redirects yourself with the \\"createRedirects\\" plugin option."
|
|
29
|
-
`);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('should reject extensions with /', () => {
|
|
33
|
-
expect(() => {
|
|
34
|
-
createToExtensionsRedirects(['/'], ['ht/ml']);
|
|
35
|
-
}).toThrowErrorMatchingInlineSnapshot(`
|
|
36
|
-
"Extension \\"ht/ml\\" contains a \\"/\\" (slash) which is not allowed.
|
|
37
|
-
If the redirect extension system is not good enough for your usecase, you can create redirects yourself with the \\"createRedirects\\" plugin option."
|
|
38
|
-
`);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test('should reject extensions with illegal url char', () => {
|
|
42
|
-
expect(() => {
|
|
43
|
-
createToExtensionsRedirects(['/'], [',']);
|
|
44
|
-
}).toThrowErrorMatchingInlineSnapshot(`
|
|
45
|
-
"Extension \\",\\" contains invalid URI characters.
|
|
46
|
-
If the redirect extension system is not good enough for your usecase, you can create redirects yourself with the \\"createRedirects\\" plugin option."
|
|
47
|
-
`);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('should create redirects from html/htm extensions', () => {
|
|
51
|
-
const ext = ['html', 'htm'];
|
|
52
|
-
expect(createToExtensionsRedirects([''], ext)).toEqual([]);
|
|
53
|
-
expect(createToExtensionsRedirects(['/'], ext)).toEqual([]);
|
|
54
|
-
expect(createToExtensionsRedirects(['/abc.html'], ext)).toEqual([
|
|
55
|
-
{from: '/abc', to: '/abc.html'},
|
|
56
|
-
]);
|
|
57
|
-
expect(createToExtensionsRedirects(['/abc.htm'], ext)).toEqual([
|
|
58
|
-
{from: '/abc', to: '/abc.htm'},
|
|
59
|
-
]);
|
|
60
|
-
expect(createToExtensionsRedirects(['/abc.xyz'], ext)).toEqual([]);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test('should create "to" redirects when relativeRoutesPath contains a prefix', () => {
|
|
64
|
-
expect(
|
|
65
|
-
createToExtensionsRedirects(['/prefix/file.html'], ['html']),
|
|
66
|
-
).toEqual([{from: '/prefix/file', to: '/prefix/file.html'}]);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test('should not create redirection for an empty extension array', () => {
|
|
70
|
-
const ext: string[] = [];
|
|
71
|
-
expect(createToExtensionsRedirects([''], ext)).toEqual([]);
|
|
72
|
-
expect(createToExtensionsRedirects(['/'], ext)).toEqual([]);
|
|
73
|
-
expect(createToExtensionsRedirects(['/abc.html'], ext)).toEqual([]);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe('createFromExtensionsRedirects', () => {
|
|
78
|
-
test('should reject empty extensions', () => {
|
|
79
|
-
expect(() => {
|
|
80
|
-
createFromExtensionsRedirects(['/'], ['.html']);
|
|
81
|
-
}).toThrowErrorMatchingInlineSnapshot(`
|
|
82
|
-
"Extension \\".html\\" contains a \\".\\" (dot) which is not allowed.
|
|
83
|
-
If the redirect extension system is not good enough for your usecase, you can create redirects yourself with the \\"createRedirects\\" plugin option."
|
|
84
|
-
`);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test('should reject extensions with .', () => {
|
|
88
|
-
expect(() => {
|
|
89
|
-
createFromExtensionsRedirects(['/'], ['.html']);
|
|
90
|
-
}).toThrowErrorMatchingInlineSnapshot(`
|
|
91
|
-
"Extension \\".html\\" contains a \\".\\" (dot) which is not allowed.
|
|
92
|
-
If the redirect extension system is not good enough for your usecase, you can create redirects yourself with the \\"createRedirects\\" plugin option."
|
|
93
|
-
`);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test('should reject extensions with /', () => {
|
|
97
|
-
expect(() => {
|
|
98
|
-
createFromExtensionsRedirects(['/'], ['ht/ml']);
|
|
99
|
-
}).toThrowErrorMatchingInlineSnapshot(`
|
|
100
|
-
"Extension \\"ht/ml\\" contains a \\"/\\" (slash) which is not allowed.
|
|
101
|
-
If the redirect extension system is not good enough for your usecase, you can create redirects yourself with the \\"createRedirects\\" plugin option."
|
|
102
|
-
`);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
test('should reject extensions with illegal url char', () => {
|
|
106
|
-
expect(() => {
|
|
107
|
-
createFromExtensionsRedirects(['/'], [',']);
|
|
108
|
-
}).toThrowErrorMatchingInlineSnapshot(`
|
|
109
|
-
"Extension \\",\\" contains invalid URI characters.
|
|
110
|
-
If the redirect extension system is not good enough for your usecase, you can create redirects yourself with the \\"createRedirects\\" plugin option."
|
|
111
|
-
`);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
test('should create redirects from html/htm extensions', () => {
|
|
115
|
-
const ext = ['html', 'htm'];
|
|
116
|
-
expect(createFromExtensionsRedirects([''], ext)).toEqual([]);
|
|
117
|
-
expect(createFromExtensionsRedirects(['/'], ext)).toEqual([]);
|
|
118
|
-
expect(createFromExtensionsRedirects(['/abc'], ext)).toEqual([
|
|
119
|
-
{from: '/abc.html', to: '/abc'},
|
|
120
|
-
{from: '/abc.htm', to: '/abc'},
|
|
121
|
-
]);
|
|
122
|
-
expect(createFromExtensionsRedirects(['/def.html'], ext)).toEqual([]);
|
|
123
|
-
expect(createFromExtensionsRedirects(['/def/'], ext)).toEqual([
|
|
124
|
-
{from: '/def.html/', to: '/def/'},
|
|
125
|
-
{from: '/def.htm/', to: '/def/'},
|
|
126
|
-
]);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
test('should create "from" redirects when relativeRoutesPath contains a prefix', () => {
|
|
130
|
-
expect(createFromExtensionsRedirects(['/prefix/file'], ['html'])).toEqual([
|
|
131
|
-
{from: '/prefix/file.html', to: '/prefix/file'},
|
|
132
|
-
]);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test('should not create redirection for an empty extension array', () => {
|
|
136
|
-
const ext: string[] = [];
|
|
137
|
-
expect(createFromExtensionsRedirects([''], ext)).toEqual([]);
|
|
138
|
-
expect(createFromExtensionsRedirects(['/'], ext)).toEqual([]);
|
|
139
|
-
expect(createFromExtensionsRedirects(['/abc'], ext)).toEqual([]);
|
|
140
|
-
expect(createFromExtensionsRedirects(['/def.html'], ext)).toEqual([]);
|
|
141
|
-
expect(createFromExtensionsRedirects(['/def/'], ext)).toEqual([]);
|
|
142
|
-
});
|
|
143
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import normalizePluginOptions, {
|
|
9
|
-
DefaultPluginOptions,
|
|
10
|
-
} from '../normalizePluginOptions';
|
|
11
|
-
import {CreateRedirectsFnOption} from '../types';
|
|
12
|
-
|
|
13
|
-
describe('normalizePluginOptions', () => {
|
|
14
|
-
test('should return default options for undefined user options', () => {
|
|
15
|
-
expect(normalizePluginOptions()).toEqual(DefaultPluginOptions);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test('should return default options for empty user options', () => {
|
|
19
|
-
expect(normalizePluginOptions()).toEqual(DefaultPluginOptions);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('should override one default options with valid user options', () => {
|
|
23
|
-
expect(
|
|
24
|
-
normalizePluginOptions({
|
|
25
|
-
toExtensions: ['html'],
|
|
26
|
-
}),
|
|
27
|
-
).toEqual({...DefaultPluginOptions, toExtensions: ['html']});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('should override all default options with valid user options', () => {
|
|
31
|
-
const createRedirects: CreateRedirectsFnOption = (_routePath: string) => [];
|
|
32
|
-
expect(
|
|
33
|
-
normalizePluginOptions({
|
|
34
|
-
fromExtensions: ['exe', 'zip'],
|
|
35
|
-
toExtensions: ['html'],
|
|
36
|
-
createRedirects,
|
|
37
|
-
redirects: [{from: '/x', to: '/y'}],
|
|
38
|
-
}),
|
|
39
|
-
).toEqual({
|
|
40
|
-
id: 'default',
|
|
41
|
-
fromExtensions: ['exe', 'zip'],
|
|
42
|
-
toExtensions: ['html'],
|
|
43
|
-
createRedirects,
|
|
44
|
-
redirects: [{from: '/x', to: '/y'}],
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('should reject bad fromExtensions user inputs', () => {
|
|
49
|
-
expect(() =>
|
|
50
|
-
normalizePluginOptions({
|
|
51
|
-
fromExtensions: [null, undefined, 123, true] as unknown as string[],
|
|
52
|
-
}),
|
|
53
|
-
).toThrowErrorMatchingSnapshot();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('should reject bad toExtensions user inputs', () => {
|
|
57
|
-
expect(() =>
|
|
58
|
-
normalizePluginOptions({
|
|
59
|
-
toExtensions: [null, undefined, 123, true] as unknown as string[],
|
|
60
|
-
}),
|
|
61
|
-
).toThrowErrorMatchingSnapshot();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test('should reject bad createRedirects user inputs', () => {
|
|
65
|
-
expect(() =>
|
|
66
|
-
normalizePluginOptions({
|
|
67
|
-
createRedirects: ['bad', 'value'] as unknown as CreateRedirectsFnOption,
|
|
68
|
-
}),
|
|
69
|
-
).toThrowErrorMatchingSnapshot();
|
|
70
|
-
});
|
|
71
|
-
});
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import {validateRedirect} from '../redirectValidation';
|
|
9
|
-
|
|
10
|
-
describe('validateRedirect', () => {
|
|
11
|
-
test('validate good redirects without throwing', () => {
|
|
12
|
-
validateRedirect({
|
|
13
|
-
from: '/fromSomePath',
|
|
14
|
-
to: '/toSomePath',
|
|
15
|
-
});
|
|
16
|
-
validateRedirect({
|
|
17
|
-
from: '/from/Some/Path',
|
|
18
|
-
to: '/toSomePath',
|
|
19
|
-
});
|
|
20
|
-
validateRedirect({
|
|
21
|
-
from: '/fromSomePath',
|
|
22
|
-
to: '/toSomePath',
|
|
23
|
-
});
|
|
24
|
-
validateRedirect({
|
|
25
|
-
from: '/fromSomePath',
|
|
26
|
-
to: '/to/Some/Path',
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('throw for bad redirects', () => {
|
|
31
|
-
expect(() =>
|
|
32
|
-
validateRedirect({
|
|
33
|
-
from: 'https://fb.com/fromSomePath',
|
|
34
|
-
to: '/toSomePath',
|
|
35
|
-
}),
|
|
36
|
-
).toThrowErrorMatchingSnapshot();
|
|
37
|
-
|
|
38
|
-
expect(() =>
|
|
39
|
-
validateRedirect({
|
|
40
|
-
from: '/fromSomePath',
|
|
41
|
-
to: 'https://fb.com/toSomePath',
|
|
42
|
-
}),
|
|
43
|
-
).toThrowErrorMatchingSnapshot();
|
|
44
|
-
|
|
45
|
-
expect(() =>
|
|
46
|
-
validateRedirect({
|
|
47
|
-
from: '/fromSomePath',
|
|
48
|
-
to: '/toSomePath?queryString=xyz',
|
|
49
|
-
}),
|
|
50
|
-
).toThrowErrorMatchingSnapshot();
|
|
51
|
-
|
|
52
|
-
expect(() =>
|
|
53
|
-
validateRedirect({
|
|
54
|
-
from: null as unknown as string,
|
|
55
|
-
to: '/toSomePath?queryString=xyz',
|
|
56
|
-
}),
|
|
57
|
-
).toThrowErrorMatchingSnapshot();
|
|
58
|
-
|
|
59
|
-
expect(() =>
|
|
60
|
-
validateRedirect({
|
|
61
|
-
from: ['heyho'] as unknown as string,
|
|
62
|
-
to: '/toSomePath?queryString=xyz',
|
|
63
|
-
}),
|
|
64
|
-
).toThrowErrorMatchingSnapshot();
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import fs from 'fs-extra';
|
|
9
|
-
import path from 'path';
|
|
10
|
-
|
|
11
|
-
import writeRedirectFiles, {
|
|
12
|
-
toRedirectFilesMetadata,
|
|
13
|
-
createToUrl,
|
|
14
|
-
} from '../writeRedirectFiles';
|
|
15
|
-
|
|
16
|
-
// Test to fix toUrl bugs we had:
|
|
17
|
-
// - https://github.com/facebook/docusaurus/issues/3886
|
|
18
|
-
// - https://github.com/facebook/docusaurus/issues/3925
|
|
19
|
-
describe('createToUrl', () => {
|
|
20
|
-
test('should create appropriate redirect urls', async () => {
|
|
21
|
-
expect(createToUrl('/', '/docs/something/else')).toEqual(
|
|
22
|
-
'/docs/something/else',
|
|
23
|
-
);
|
|
24
|
-
expect(createToUrl('/', '/docs/something/else/')).toEqual(
|
|
25
|
-
'/docs/something/else/',
|
|
26
|
-
);
|
|
27
|
-
expect(createToUrl('/', 'docs/something/else')).toEqual(
|
|
28
|
-
'/docs/something/else',
|
|
29
|
-
);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('should create appropriate redirect urls with baseUrl', async () => {
|
|
33
|
-
expect(createToUrl('/baseUrl/', '/docs/something/else')).toEqual(
|
|
34
|
-
'/baseUrl/docs/something/else',
|
|
35
|
-
);
|
|
36
|
-
expect(createToUrl('/baseUrl/', '/docs/something/else/')).toEqual(
|
|
37
|
-
'/baseUrl/docs/something/else/',
|
|
38
|
-
);
|
|
39
|
-
expect(createToUrl('/baseUrl/', 'docs/something/else')).toEqual(
|
|
40
|
-
'/baseUrl/docs/something/else',
|
|
41
|
-
);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
describe('toRedirectFilesMetadata', () => {
|
|
46
|
-
test('should create appropriate metadata trailingSlash=undefined', async () => {
|
|
47
|
-
const pluginContext = {
|
|
48
|
-
outDir: '/tmp/someFixedOutDir',
|
|
49
|
-
baseUrl: 'https://docusaurus.io',
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const redirectFiles = toRedirectFilesMetadata(
|
|
53
|
-
[
|
|
54
|
-
{from: '/abc.html', to: '/abc'},
|
|
55
|
-
{from: '/def', to: '/def.html'},
|
|
56
|
-
{from: '/xyz', to: '/'},
|
|
57
|
-
],
|
|
58
|
-
pluginContext,
|
|
59
|
-
undefined,
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
expect(redirectFiles.map((f) => f.fileAbsolutePath)).toEqual([
|
|
63
|
-
path.join(pluginContext.outDir, '/abc.html/index.html'),
|
|
64
|
-
path.join(pluginContext.outDir, '/def/index.html'),
|
|
65
|
-
path.join(pluginContext.outDir, '/xyz/index.html'),
|
|
66
|
-
]);
|
|
67
|
-
|
|
68
|
-
expect(redirectFiles.map((f) => f.fileContent)).toMatchSnapshot(
|
|
69
|
-
'fileContent',
|
|
70
|
-
);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
test('should create appropriate metadata trailingSlash=true', async () => {
|
|
74
|
-
const pluginContext = {
|
|
75
|
-
outDir: '/tmp/someFixedOutDir',
|
|
76
|
-
baseUrl: 'https://docusaurus.io',
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const redirectFiles = toRedirectFilesMetadata(
|
|
80
|
-
[
|
|
81
|
-
{from: '/abc.html', to: '/abc'},
|
|
82
|
-
{from: '/def', to: '/def.html'},
|
|
83
|
-
{from: '/xyz', to: '/'},
|
|
84
|
-
],
|
|
85
|
-
pluginContext,
|
|
86
|
-
true,
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
expect(redirectFiles.map((f) => f.fileAbsolutePath)).toEqual([
|
|
90
|
-
path.join(pluginContext.outDir, '/abc.html/index.html'),
|
|
91
|
-
path.join(pluginContext.outDir, '/def/index.html'),
|
|
92
|
-
path.join(pluginContext.outDir, '/xyz/index.html'),
|
|
93
|
-
]);
|
|
94
|
-
|
|
95
|
-
expect(redirectFiles.map((f) => f.fileContent)).toMatchSnapshot(
|
|
96
|
-
'fileContent',
|
|
97
|
-
);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test('should create appropriate metadata trailingSlash=false', async () => {
|
|
101
|
-
const pluginContext = {
|
|
102
|
-
outDir: '/tmp/someFixedOutDir',
|
|
103
|
-
baseUrl: 'https://docusaurus.io',
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const redirectFiles = toRedirectFilesMetadata(
|
|
107
|
-
[
|
|
108
|
-
{from: '/abc.html', to: '/abc'},
|
|
109
|
-
{from: '/def', to: '/def.html'},
|
|
110
|
-
{from: '/xyz', to: '/'},
|
|
111
|
-
],
|
|
112
|
-
pluginContext,
|
|
113
|
-
false,
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
expect(redirectFiles.map((f) => f.fileAbsolutePath)).toEqual([
|
|
117
|
-
// path.join(pluginContext.outDir, '/abc.html/index.html'), // Can't be used because /abc.html already exists, and file/folder can't share same name on Unix!
|
|
118
|
-
path.join(pluginContext.outDir, '/abc.html.html'), // Weird but on purpose!
|
|
119
|
-
path.join(pluginContext.outDir, '/def/index.html'),
|
|
120
|
-
path.join(pluginContext.outDir, '/xyz/index.html'),
|
|
121
|
-
]);
|
|
122
|
-
|
|
123
|
-
expect(redirectFiles.map((f) => f.fileContent)).toMatchSnapshot(
|
|
124
|
-
'fileContent',
|
|
125
|
-
);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
test('should create appropriate metadata for root baseUrl', async () => {
|
|
129
|
-
const pluginContext = {
|
|
130
|
-
outDir: '/tmp/someFixedOutDir',
|
|
131
|
-
baseUrl: '/',
|
|
132
|
-
};
|
|
133
|
-
const redirectFiles = toRedirectFilesMetadata(
|
|
134
|
-
[{from: '/abc.html', to: '/abc'}],
|
|
135
|
-
pluginContext,
|
|
136
|
-
undefined,
|
|
137
|
-
);
|
|
138
|
-
expect(redirectFiles.map((f) => f.fileContent)).toMatchSnapshot(
|
|
139
|
-
'fileContent baseUrl=/',
|
|
140
|
-
);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
test('should create appropriate metadata for empty baseUrl', async () => {
|
|
144
|
-
const pluginContext = {
|
|
145
|
-
outDir: '/tmp/someFixedOutDir',
|
|
146
|
-
baseUrl: '',
|
|
147
|
-
};
|
|
148
|
-
const redirectFiles = toRedirectFilesMetadata(
|
|
149
|
-
[{from: '/abc.html', to: '/abc'}],
|
|
150
|
-
pluginContext,
|
|
151
|
-
undefined,
|
|
152
|
-
);
|
|
153
|
-
expect(redirectFiles.map((f) => f.fileContent)).toMatchSnapshot(
|
|
154
|
-
'fileContent baseUrl=empty',
|
|
155
|
-
);
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
describe('writeRedirectFiles', () => {
|
|
160
|
-
test('write the files', async () => {
|
|
161
|
-
const outDir = `/tmp/docusaurus_tests_${Math.random()}`;
|
|
162
|
-
|
|
163
|
-
const filesMetadata = [
|
|
164
|
-
{
|
|
165
|
-
fileAbsolutePath: path.join(outDir, 'someFileName'),
|
|
166
|
-
fileContent: 'content 1',
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
fileAbsolutePath: path.join(outDir, '/some/nested/filename'),
|
|
170
|
-
fileContent: 'content 2',
|
|
171
|
-
},
|
|
172
|
-
];
|
|
173
|
-
|
|
174
|
-
await writeRedirectFiles(filesMetadata);
|
|
175
|
-
|
|
176
|
-
await expect(
|
|
177
|
-
fs.readFile(filesMetadata[0].fileAbsolutePath, 'utf8'),
|
|
178
|
-
).resolves.toEqual('content 1');
|
|
179
|
-
|
|
180
|
-
await expect(
|
|
181
|
-
fs.readFile(filesMetadata[1].fileAbsolutePath, 'utf8'),
|
|
182
|
-
).resolves.toEqual('content 2');
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
test('avoid overwriting existing files', async () => {
|
|
186
|
-
const outDir = `/tmp/docusaurus_tests_${Math.random()}`;
|
|
187
|
-
|
|
188
|
-
const filesMetadata = [
|
|
189
|
-
{
|
|
190
|
-
fileAbsolutePath: path.join(outDir, 'someFileName/index.html'),
|
|
191
|
-
fileContent: 'content 1',
|
|
192
|
-
},
|
|
193
|
-
];
|
|
194
|
-
|
|
195
|
-
await fs.ensureDir(path.dirname(filesMetadata[0].fileAbsolutePath));
|
|
196
|
-
await fs.writeFile(
|
|
197
|
-
filesMetadata[0].fileAbsolutePath,
|
|
198
|
-
'file already exists!',
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
await expect(writeRedirectFiles(filesMetadata)).rejects.toThrowError(
|
|
202
|
-
`Redirect file creation error for "${filesMetadata[0].fileAbsolutePath}" path: Error: The redirect plugin is not supposed to override existing files.`,
|
|
203
|
-
);
|
|
204
|
-
});
|
|
205
|
-
});
|