gatsby 3.5.0 → 3.5.1
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/CHANGELOG.md +7 -0
- package/cache-dir/commonjs/find-path.js +8 -0
- package/cache-dir/commonjs/navigation.js +5 -30
- package/cache-dir/commonjs/pages.json +1 -0
- package/cache-dir/commonjs/redirect-utils.js +30 -0
- package/cache-dir/commonjs/redirects.json +1 -0
- package/cache-dir/find-path.js +6 -0
- package/cache-dir/navigation.js +4 -31
- package/cache-dir/redirect-utils.js +22 -0
- package/dist/bootstrap/redirects-writer.js +28 -18
- package/dist/bootstrap/redirects-writer.js.map +1 -1
- package/gatsby-admin-public/_headers.json +1 -1
- package/gatsby-admin-public/{app-290a2b18c2bf478892b5.js → app-fefc4501fd27622da1b1.js} +3 -3
- package/gatsby-admin-public/{app-290a2b18c2bf478892b5.js.LICENSE.txt → app-fefc4501fd27622da1b1.js.LICENSE.txt} +0 -0
- package/gatsby-admin-public/app-fefc4501fd27622da1b1.js.map +1 -0
- package/gatsby-admin-public/chunk-map.json +1 -1
- package/gatsby-admin-public/index.html +1 -1
- package/gatsby-admin-public/page-data/app-data.json +1 -1
- package/gatsby-admin-public/pages/index.html +1 -1
- package/gatsby-admin-public/plugins/index.html +1 -1
- package/gatsby-admin-public/recipe/index.html +1 -1
- package/gatsby-admin-public/recipes/index.html +1 -1
- package/gatsby-admin-public/webpack.stats.json +1 -1
- package/package.json +3 -3
- package/gatsby-admin-public/app-290a2b18c2bf478892b5.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.5.1](https://github.com/gatsbyjs/gatsby/compare/gatsby@3.5.0...gatsby@3.5.1) (2021-05-19)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **gatsby:** preload and prefetches check for in-browser redirects ([#31366](https://github.com/gatsbyjs/gatsby/issues/31366)) ([#31480](https://github.com/gatsbyjs/gatsby/issues/31480)) ([e6e7eec](https://github.com/gatsbyjs/gatsby/commit/e6e7eec161fd1436d29d492e720c5f1031a3aa66))
|
|
11
|
+
- **tests:** update cheerio snapshots ([#31298](https://github.com/gatsbyjs/gatsby/issues/31298)) ([#31483](https://github.com/gatsbyjs/gatsby/issues/31483)) ([67a4fce](https://github.com/gatsbyjs/gatsby/commit/67a4fcef4651443cbe89923d4ac80e5600d94c41))
|
|
12
|
+
|
|
6
13
|
# [3.5.0](https://github.com/gatsbyjs/gatsby/compare/gatsby@3.5.0-next.4...gatsby@3.5.0) (2021-05-11)
|
|
7
14
|
|
|
8
15
|
### Bug Fixes
|
|
@@ -11,6 +11,8 @@ var _stripPrefix = _interopRequireDefault(require("./strip-prefix"));
|
|
|
11
11
|
|
|
12
12
|
var _normalizePagePath = _interopRequireDefault(require("./normalize-page-path"));
|
|
13
13
|
|
|
14
|
+
var _redirectUtils = require("./redirect-utils.js");
|
|
15
|
+
|
|
14
16
|
const pathCache = new Map();
|
|
15
17
|
let matchPaths = [];
|
|
16
18
|
|
|
@@ -124,6 +126,12 @@ const findPath = rawPathname => {
|
|
|
124
126
|
return pathCache.get(trimmedPathname);
|
|
125
127
|
}
|
|
126
128
|
|
|
129
|
+
const redirect = (0, _redirectUtils.maybeGetBrowserRedirect)(rawPathname);
|
|
130
|
+
|
|
131
|
+
if (redirect) {
|
|
132
|
+
return findPath(redirect.toPath);
|
|
133
|
+
}
|
|
134
|
+
|
|
127
135
|
let foundPath = findMatchPath(trimmedPathname);
|
|
128
136
|
|
|
129
137
|
if (!foundPath) {
|
|
@@ -15,7 +15,9 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
15
15
|
|
|
16
16
|
var _loader = _interopRequireWildcard(require("./loader"));
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _redirectUtils = require("./redirect-utils.js");
|
|
19
|
+
|
|
20
|
+
exports.maybeGetBrowserRedirect = _redirectUtils.maybeGetBrowserRedirect;
|
|
19
21
|
|
|
20
22
|
var _apiRunnerBrowser = require("./api-runner-browser");
|
|
21
23
|
|
|
@@ -33,32 +35,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
33
35
|
|
|
34
36
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
37
|
|
|
36
|
-
// Convert to a map for faster lookup in maybeRedirect()
|
|
37
|
-
const redirectMap = new Map();
|
|
38
|
-
const redirectIgnoreCaseMap = new Map();
|
|
39
|
-
|
|
40
|
-
_redirects.default.forEach(redirect => {
|
|
41
|
-
if (redirect.ignoreCase) {
|
|
42
|
-
redirectIgnoreCaseMap.set(redirect.fromPath, redirect);
|
|
43
|
-
} else {
|
|
44
|
-
redirectMap.set(redirect.fromPath, redirect);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
38
|
function maybeRedirect(pathname) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (!redirect) {
|
|
52
|
-
redirect = redirectIgnoreCaseMap.get(pathname.toLowerCase());
|
|
53
|
-
}
|
|
39
|
+
const redirect = (0, _redirectUtils.maybeGetBrowserRedirect)(pathname);
|
|
54
40
|
|
|
55
41
|
if (redirect != null) {
|
|
56
|
-
if (process.env.NODE_ENV !== `production`) {
|
|
57
|
-
if (!_loader.default.isPageNotFound(pathname)) {
|
|
58
|
-
console.error(`The route "${pathname}" matches both a page and a redirect; this is probably not intentional.`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
42
|
window.___replace(redirect.toPath);
|
|
63
43
|
|
|
64
44
|
return true;
|
|
@@ -105,14 +85,9 @@ const navigate = (to, options = {}) => {
|
|
|
105
85
|
let {
|
|
106
86
|
pathname
|
|
107
87
|
} = (0, _gatsbyLink.parsePath)(to);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (!redirect) {
|
|
111
|
-
redirect = redirectIgnoreCaseMap.get(pathname.toLowerCase());
|
|
112
|
-
} // If we're redirecting, just replace the passed in pathname
|
|
88
|
+
const redirect = (0, _redirectUtils.maybeGetBrowserRedirect)(pathname); // If we're redirecting, just replace the passed in pathname
|
|
113
89
|
// to the one we want to redirect to.
|
|
114
90
|
|
|
115
|
-
|
|
116
91
|
if (redirect) {
|
|
117
92
|
to = redirect.toPath;
|
|
118
93
|
pathname = (0, _gatsbyLink.parsePath)(to).pathname;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
exports.maybeGetBrowserRedirect = maybeGetBrowserRedirect;
|
|
7
|
+
|
|
8
|
+
var _redirects = _interopRequireDefault(require("./redirects.json"));
|
|
9
|
+
|
|
10
|
+
// Convert to a map for faster lookup in maybeRedirect()
|
|
11
|
+
const redirectMap = new Map();
|
|
12
|
+
const redirectIgnoreCaseMap = new Map();
|
|
13
|
+
|
|
14
|
+
_redirects.default.forEach(redirect => {
|
|
15
|
+
if (redirect.ignoreCase) {
|
|
16
|
+
redirectIgnoreCaseMap.set(redirect.fromPath, redirect);
|
|
17
|
+
} else {
|
|
18
|
+
redirectMap.set(redirect.fromPath, redirect);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
function maybeGetBrowserRedirect(pathname) {
|
|
23
|
+
let redirect = redirectMap.get(pathname);
|
|
24
|
+
|
|
25
|
+
if (!redirect) {
|
|
26
|
+
redirect = redirectIgnoreCaseMap.get(pathname.toLowerCase());
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return redirect;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
package/cache-dir/find-path.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { pick } from "@gatsbyjs/reach-router/lib/utils"
|
|
2
2
|
import stripPrefix from "./strip-prefix"
|
|
3
3
|
import normalizePagePath from "./normalize-page-path"
|
|
4
|
+
import { maybeGetBrowserRedirect } from "./redirect-utils.js"
|
|
4
5
|
|
|
5
6
|
const pathCache = new Map()
|
|
6
7
|
let matchPaths = []
|
|
@@ -115,6 +116,11 @@ export const findPath = rawPathname => {
|
|
|
115
116
|
return pathCache.get(trimmedPathname)
|
|
116
117
|
}
|
|
117
118
|
|
|
119
|
+
const redirect = maybeGetBrowserRedirect(rawPathname)
|
|
120
|
+
if (redirect) {
|
|
121
|
+
return findPath(redirect.toPath)
|
|
122
|
+
}
|
|
123
|
+
|
|
118
124
|
let foundPath = findMatchPath(trimmedPathname)
|
|
119
125
|
|
|
120
126
|
if (!foundPath) {
|
package/cache-dir/navigation.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import PropTypes from "prop-types"
|
|
3
3
|
import loader, { PageResourceStatus } from "./loader"
|
|
4
|
-
import
|
|
4
|
+
import { maybeGetBrowserRedirect } from "./redirect-utils.js"
|
|
5
5
|
import { apiRunner } from "./api-runner-browser"
|
|
6
6
|
import emitter from "./emitter"
|
|
7
7
|
import { RouteAnnouncerProps } from "./route-announcer-props"
|
|
@@ -9,34 +9,10 @@ import { navigate as reachNavigate } from "@gatsbyjs/reach-router"
|
|
|
9
9
|
import { globalHistory } from "@gatsbyjs/reach-router/lib/history"
|
|
10
10
|
import { parsePath } from "gatsby-link"
|
|
11
11
|
|
|
12
|
-
// Convert to a map for faster lookup in maybeRedirect()
|
|
13
|
-
|
|
14
|
-
const redirectMap = new Map()
|
|
15
|
-
const redirectIgnoreCaseMap = new Map()
|
|
16
|
-
|
|
17
|
-
redirects.forEach(redirect => {
|
|
18
|
-
if (redirect.ignoreCase) {
|
|
19
|
-
redirectIgnoreCaseMap.set(redirect.fromPath, redirect)
|
|
20
|
-
} else {
|
|
21
|
-
redirectMap.set(redirect.fromPath, redirect)
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
|
|
25
12
|
function maybeRedirect(pathname) {
|
|
26
|
-
|
|
27
|
-
if (!redirect) {
|
|
28
|
-
redirect = redirectIgnoreCaseMap.get(pathname.toLowerCase())
|
|
29
|
-
}
|
|
13
|
+
const redirect = maybeGetBrowserRedirect(pathname)
|
|
30
14
|
|
|
31
15
|
if (redirect != null) {
|
|
32
|
-
if (process.env.NODE_ENV !== `production`) {
|
|
33
|
-
if (!loader.isPageNotFound(pathname)) {
|
|
34
|
-
console.error(
|
|
35
|
-
`The route "${pathname}" matches both a page and a redirect; this is probably not intentional.`
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
16
|
window.___replace(redirect.toPath)
|
|
41
17
|
return true
|
|
42
18
|
} else {
|
|
@@ -72,10 +48,7 @@ const navigate = (to, options = {}) => {
|
|
|
72
48
|
}
|
|
73
49
|
|
|
74
50
|
let { pathname } = parsePath(to)
|
|
75
|
-
|
|
76
|
-
if (!redirect) {
|
|
77
|
-
redirect = redirectIgnoreCaseMap.get(pathname.toLowerCase())
|
|
78
|
-
}
|
|
51
|
+
const redirect = maybeGetBrowserRedirect(pathname)
|
|
79
52
|
|
|
80
53
|
// If we're redirecting, just replace the passed in pathname
|
|
81
54
|
// to the one we want to redirect to.
|
|
@@ -270,4 +243,4 @@ RouteUpdates.propTypes = {
|
|
|
270
243
|
location: PropTypes.object.isRequired,
|
|
271
244
|
}
|
|
272
245
|
|
|
273
|
-
export { init, shouldUpdateScroll, RouteUpdates }
|
|
246
|
+
export { init, shouldUpdateScroll, RouteUpdates, maybeGetBrowserRedirect }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import redirects from "./redirects.json"
|
|
2
|
+
|
|
3
|
+
// Convert to a map for faster lookup in maybeRedirect()
|
|
4
|
+
|
|
5
|
+
const redirectMap = new Map()
|
|
6
|
+
const redirectIgnoreCaseMap = new Map()
|
|
7
|
+
|
|
8
|
+
redirects.forEach(redirect => {
|
|
9
|
+
if (redirect.ignoreCase) {
|
|
10
|
+
redirectIgnoreCaseMap.set(redirect.fromPath, redirect)
|
|
11
|
+
} else {
|
|
12
|
+
redirectMap.set(redirect.fromPath, redirect)
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export function maybeGetBrowserRedirect(pathname) {
|
|
17
|
+
let redirect = redirectMap.get(pathname)
|
|
18
|
+
if (!redirect) {
|
|
19
|
+
redirect = redirectIgnoreCaseMap.get(pathname.toLowerCase())
|
|
20
|
+
}
|
|
21
|
+
return redirect
|
|
22
|
+
}
|
|
@@ -15,6 +15,8 @@ var _redux = require("../redux");
|
|
|
15
15
|
|
|
16
16
|
var _gatsbyCoreUtils = require("gatsby-core-utils");
|
|
17
17
|
|
|
18
|
+
var _reporter = _interopRequireDefault(require("gatsby-cli/lib/reporter"));
|
|
19
|
+
|
|
18
20
|
let lastHash = null;
|
|
19
21
|
let bootstrapFinished = false;
|
|
20
22
|
|
|
@@ -23,24 +25,32 @@ const writeRedirects = async () => {
|
|
|
23
25
|
|
|
24
26
|
const {
|
|
25
27
|
program,
|
|
26
|
-
redirects
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
redirects,
|
|
29
|
+
pages
|
|
30
|
+
} = _redux.store.getState();
|
|
31
|
+
|
|
32
|
+
const redirectMatchingPageWarnings = [];
|
|
33
|
+
const browserRedirects = [];
|
|
34
|
+
|
|
35
|
+
for (const redirect of redirects) {
|
|
36
|
+
const alternativePath = redirect.fromPath.endsWith(`/`) ? redirect.fromPath.substr(0, redirect.fromPath.length - 1) : redirect.fromPath + `/`;
|
|
37
|
+
let hasSamePage;
|
|
38
|
+
|
|
39
|
+
if ((hasSamePage = pages.has(redirect.fromPath)) || pages.has(alternativePath)) {
|
|
40
|
+
redirectMatchingPageWarnings.push(` - page: "${hasSamePage ? redirect.fromPath : alternativePath}" and redirect: "${redirect.fromPath}" -> "${redirect.toPath}"`);
|
|
41
|
+
} // Filter for redirects that are meant for the browser.
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
if (redirect.redirectInBrowser) {
|
|
45
|
+
browserRedirects.push({ ...redirect,
|
|
46
|
+
fromPath: redirect.ignoreCase ? redirect.fromPath.toLowerCase() : redirect.fromPath
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (redirectMatchingPageWarnings.length > 0) {
|
|
52
|
+
_reporter.default.warn(`There are routes that match both page and redirect. It will result in page not being accessible; this is probably not intentional:\n${redirectMatchingPageWarnings.join(`\n`)}`);
|
|
53
|
+
}
|
|
44
54
|
|
|
45
55
|
const newHash = _crypto.default.createHash(`md5`).update(JSON.stringify(browserRedirects)).digest(`hex`);
|
|
46
56
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bootstrap/redirects-writer.ts"],"names":["lastHash","bootstrapFinished","writeRedirects","program","redirects","store","getState","browserRedirects","
|
|
1
|
+
{"version":3,"sources":["../../src/bootstrap/redirects-writer.ts"],"names":["lastHash","bootstrapFinished","writeRedirects","program","redirects","pages","store","getState","redirectMatchingPageWarnings","browserRedirects","redirect","alternativePath","fromPath","endsWith","substr","length","hasSamePage","has","push","toPath","redirectInBrowser","ignoreCase","toLowerCase","reporter","warn","join","newHash","crypto","createHash","update","JSON","stringify","digest","fs","writeFile","directory","debouncedWriteRedirects","_","debounce","startRedirectListener","emitter","on"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA,IAAIA,QAAuB,GAAG,IAA9B;AACA,IAAIC,iBAAiB,GAAG,KAAxB;;AAEO,MAAMC,cAAc,GAAG,YAA2B;AACvDD,EAAAA,iBAAiB,GAAG,IAApB;;AAEA,QAAM;AAAEE,IAAAA,OAAF;AAAWC,IAAAA,SAAX;AAAsBC,IAAAA;AAAtB,MAAgCC,aAAMC,QAAN,EAAtC;;AAEA,QAAMC,4BAA2C,GAAG,EAApD;AACA,QAAMC,gBAAkC,GAAG,EAA3C;;AAEA,OAAK,MAAMC,QAAX,IAAuBN,SAAvB,EAAkC;AAChC,UAAMO,eAAe,GAAGD,QAAQ,CAACE,QAAT,CAAkBC,QAAlB,CAA4B,GAA5B,IACpBH,QAAQ,CAACE,QAAT,CAAkBE,MAAlB,CAAyB,CAAzB,EAA4BJ,QAAQ,CAACE,QAAT,CAAkBG,MAAlB,GAA2B,CAAvD,CADoB,GAEpBL,QAAQ,CAACE,QAAT,GAAqB,GAFzB;AAIA,QAAII,WAAJ;;AAEA,QACE,CAACA,WAAW,GAAGX,KAAK,CAACY,GAAN,CAAUP,QAAQ,CAACE,QAAnB,CAAf,KACAP,KAAK,CAACY,GAAN,CAAUN,eAAV,CAFF,EAGE;AACAH,MAAAA,4BAA4B,CAACU,IAA7B,CACG,aACCF,WAAW,GAAGN,QAAQ,CAACE,QAAZ,GAAuBD,eACnC,oBAAmBD,QAAQ,CAACE,QAAS,SAAQF,QAAQ,CAACS,MAAO,GAHhE;AAKD,KAhB+B,CAiBhC;;;AACA,QAAIT,QAAQ,CAACU,iBAAb,EAAgC;AAC9BX,MAAAA,gBAAgB,CAACS,IAAjB,CAAsB,EACpB,GAAGR,QADiB;AAEpBE,QAAAA,QAAQ,EAAEF,QAAQ,CAACW,UAAT,GACNX,QAAQ,CAACE,QAAT,CAAkBU,WAAlB,EADM,GAENZ,QAAQ,CAACE;AAJO,OAAtB;AAMD;AACF;;AAED,MAAIJ,4BAA4B,CAACO,MAA7B,GAAsC,CAA1C,EAA6C;AAC3CQ,sBAASC,IAAT,CACG,uIAAsIhB,4BAA4B,CAACiB,IAA7B,CACpI,IADoI,CAErI,EAHJ;AAKD;;AAED,QAAMC,OAAO,GAAGC,gBACbC,UADa,CACD,KADC,EAEbC,MAFa,CAENC,IAAI,CAACC,SAAL,CAAetB,gBAAf,CAFM,EAGbuB,MAHa,CAGL,KAHK,CAAhB;;AAKA,MAAIN,OAAO,KAAK1B,QAAhB,EAA0B;AACxB;AACD;;AAEDA,EAAAA,QAAQ,GAAG0B,OAAX;AAEA,QAAMO,iBAAGC,SAAH,CACJ,+BAAS/B,OAAO,CAACgC,SAAjB,EAA6B,uBAA7B,CADI,EAEJL,IAAI,CAACC,SAAL,CAAetB,gBAAf,EAAiC,IAAjC,EAAuC,CAAvC,CAFI,CAAN;AAID,CA3DM;;;;AA6DP,MAAM2B,uBAAuB,GAAGC,gBAAEC,QAAF,CAAW,MAAM;AAC/C;AACA,MAAIrC,iBAAJ,EAAuB;AACrBC,IAAAA,cAAc;AACf;AACF,CAL+B,EAK7B,GAL6B,CAAhC;;AAOO,MAAMqC,qBAAqB,GAAG,MAAY;AAC/CC,iBAAQC,EAAR,CAAY,iBAAZ,EAA8B,MAAM;AAClCL,IAAAA,uBAAuB;AACxB,GAFD;AAGD,CAJM","sourcesContent":["import _ from \"lodash\"\nimport crypto from \"crypto\"\nimport fs from \"fs-extra\"\nimport { store, emitter } from \"../redux\"\nimport { IRedirect } from \"../redux/types\"\nimport { joinPath } from \"gatsby-core-utils\"\nimport reporter from \"gatsby-cli/lib/reporter\"\n\nlet lastHash: string | null = null\nlet bootstrapFinished = false\n\nexport const writeRedirects = async (): Promise<void> => {\n bootstrapFinished = true\n\n const { program, redirects, pages } = store.getState()\n\n const redirectMatchingPageWarnings: Array<string> = []\n const browserRedirects: Array<IRedirect> = []\n\n for (const redirect of redirects) {\n const alternativePath = redirect.fromPath.endsWith(`/`)\n ? redirect.fromPath.substr(0, redirect.fromPath.length - 1)\n : redirect.fromPath + `/`\n\n let hasSamePage: boolean\n\n if (\n (hasSamePage = pages.has(redirect.fromPath)) ||\n pages.has(alternativePath)\n ) {\n redirectMatchingPageWarnings.push(\n ` - page: \"${\n hasSamePage ? redirect.fromPath : alternativePath\n }\" and redirect: \"${redirect.fromPath}\" -> \"${redirect.toPath}\"`\n )\n }\n // Filter for redirects that are meant for the browser.\n if (redirect.redirectInBrowser) {\n browserRedirects.push({\n ...redirect,\n fromPath: redirect.ignoreCase\n ? redirect.fromPath.toLowerCase()\n : redirect.fromPath,\n })\n }\n }\n\n if (redirectMatchingPageWarnings.length > 0) {\n reporter.warn(\n `There are routes that match both page and redirect. It will result in page not being accessible; this is probably not intentional:\\n${redirectMatchingPageWarnings.join(\n `\\n`\n )}`\n )\n }\n\n const newHash = crypto\n .createHash(`md5`)\n .update(JSON.stringify(browserRedirects))\n .digest(`hex`)\n\n if (newHash === lastHash) {\n return\n }\n\n lastHash = newHash\n\n await fs.writeFile(\n joinPath(program.directory, `.cache/redirects.json`),\n JSON.stringify(browserRedirects, null, 2)\n )\n}\n\nconst debouncedWriteRedirects = _.debounce(() => {\n // Don't write redirects again until bootstrap has finished.\n if (bootstrapFinished) {\n writeRedirects()\n }\n}, 250)\n\nexport const startRedirectListener = (): void => {\n emitter.on(`CREATE_REDIRECT`, () => {\n debouncedWriteRedirects()\n })\n}\n"],"file":"redirects-writer.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"/*":["X-Frame-Options: DENY","X-XSS-Protection: 1; mode=block","X-Content-Type-Options: nosniff","Referrer-Policy: same-origin"],"/e2852b4470dcb2615e49edcd9de2a3c8119d4bec-e8377efa018b5b632652.js":["Cache-Control: public, max-age=31536000, immutable"],"/c432bec7e9afb3443fd639df9e5f119e13575cf7-52c66354c9e40dafee82.js":["Cache-Control: public, max-age=31536000, immutable"],"/854a7ef1f34af0aefbdfdd9304a0c00251662775-aa0380a0e650c4e20230.js":["Cache-Control: public, max-age=31536000, immutable"],"/component---src-pages-index-tsx-e14ac7eb589bdb79743f.js":["Cache-Control: public, max-age=31536000, immutable"],"/component---src-pages-pages-tsx-2fcb822e2606c12b2ea2.js":["Cache-Control: public, max-age=31536000, immutable"],"/69bd6bf3-f374cd2e1ee0e375f045.js":["Cache-Control: public, max-age=31536000, immutable"],"/4c744e84-130bfe682cbb8896de3a.js":["Cache-Control: public, max-age=31536000, immutable"],"/784b2cee55c07b638f20445dec340adf9f1888a3-ff699326697a9b0f1141.js":["Cache-Control: public, max-age=31536000, immutable"],"/component---src-pages-plugins-tsx-0473a7c3e1abdf54b13c.js":["Cache-Control: public, max-age=31536000, immutable"],"/component---src-pages-recipe-js-cb2967f252bd2a91f542.js":["Cache-Control: public, max-age=31536000, immutable"],"/component---src-pages-recipes-tsx-d2dfd910c146829d70ac.js":["Cache-Control: public, max-age=31536000, immutable"],"/webpack-runtime-9172ba536ddfa2136b81.js":["Cache-Control: public, max-age=31536000, immutable"],"/framework-b24cde22b86a9930317b.js":["Cache-Control: public, max-age=31536000, immutable"],"/styles.ac2d3128404ecdaeec67.css":["Cache-Control: public, max-age=31536000, immutable"],"/app-
|
|
1
|
+
{"/*":["X-Frame-Options: DENY","X-XSS-Protection: 1; mode=block","X-Content-Type-Options: nosniff","Referrer-Policy: same-origin"],"/e2852b4470dcb2615e49edcd9de2a3c8119d4bec-e8377efa018b5b632652.js":["Cache-Control: public, max-age=31536000, immutable"],"/c432bec7e9afb3443fd639df9e5f119e13575cf7-52c66354c9e40dafee82.js":["Cache-Control: public, max-age=31536000, immutable"],"/854a7ef1f34af0aefbdfdd9304a0c00251662775-aa0380a0e650c4e20230.js":["Cache-Control: public, max-age=31536000, immutable"],"/component---src-pages-index-tsx-e14ac7eb589bdb79743f.js":["Cache-Control: public, max-age=31536000, immutable"],"/component---src-pages-pages-tsx-2fcb822e2606c12b2ea2.js":["Cache-Control: public, max-age=31536000, immutable"],"/69bd6bf3-f374cd2e1ee0e375f045.js":["Cache-Control: public, max-age=31536000, immutable"],"/4c744e84-130bfe682cbb8896de3a.js":["Cache-Control: public, max-age=31536000, immutable"],"/784b2cee55c07b638f20445dec340adf9f1888a3-ff699326697a9b0f1141.js":["Cache-Control: public, max-age=31536000, immutable"],"/component---src-pages-plugins-tsx-0473a7c3e1abdf54b13c.js":["Cache-Control: public, max-age=31536000, immutable"],"/component---src-pages-recipe-js-cb2967f252bd2a91f542.js":["Cache-Control: public, max-age=31536000, immutable"],"/component---src-pages-recipes-tsx-d2dfd910c146829d70ac.js":["Cache-Control: public, max-age=31536000, immutable"],"/webpack-runtime-9172ba536ddfa2136b81.js":["Cache-Control: public, max-age=31536000, immutable"],"/framework-b24cde22b86a9930317b.js":["Cache-Control: public, max-age=31536000, immutable"],"/styles.ac2d3128404ecdaeec67.css":["Cache-Control: public, max-age=31536000, immutable"],"/app-fefc4501fd27622da1b1.js":["Cache-Control: public, max-age=31536000, immutable"],"/static/*":["Cache-Control: public, max-age=31536000, immutable"],"/sw.js":["Cache-Control: public, max-age=0, must-revalidate"],"/___admin/":["Link: </___admin/webpack-runtime-9172ba536ddfa2136b81.js>; rel=preload; as=script; nopush","Link: </___admin/framework-b24cde22b86a9930317b.js>; rel=preload; as=script; nopush","Link: </___admin/app-fefc4501fd27622da1b1.js>; rel=preload; as=script; nopush","Link: </___admin/e2852b4470dcb2615e49edcd9de2a3c8119d4bec-e8377efa018b5b632652.js>; rel=preload; as=script; nopush","Link: </___admin/c432bec7e9afb3443fd639df9e5f119e13575cf7-52c66354c9e40dafee82.js>; rel=preload; as=script; nopush","Link: </___admin/854a7ef1f34af0aefbdfdd9304a0c00251662775-aa0380a0e650c4e20230.js>; rel=preload; as=script; nopush","Link: </___admin/component---src-pages-index-tsx-e14ac7eb589bdb79743f.js>; rel=preload; as=script; nopush","Link: </___admin/page-data/app-data.json>; rel=preload; as=fetch; crossorigin; nopush","Link: </___admin/page-data/index/page-data.json>; rel=preload; as=fetch; crossorigin; nopush"],"/___admin/pages/":["Link: </___admin/webpack-runtime-9172ba536ddfa2136b81.js>; rel=preload; as=script; nopush","Link: </___admin/framework-b24cde22b86a9930317b.js>; rel=preload; as=script; nopush","Link: </___admin/app-fefc4501fd27622da1b1.js>; rel=preload; as=script; nopush","Link: </___admin/component---src-pages-pages-tsx-2fcb822e2606c12b2ea2.js>; rel=preload; as=script; nopush","Link: </___admin/page-data/app-data.json>; rel=preload; as=fetch; crossorigin; nopush","Link: </___admin/page-data/pages/page-data.json>; rel=preload; as=fetch; crossorigin; nopush"],"/___admin/plugins/":["Link: </___admin/webpack-runtime-9172ba536ddfa2136b81.js>; rel=preload; as=script; nopush","Link: </___admin/framework-b24cde22b86a9930317b.js>; rel=preload; as=script; nopush","Link: </___admin/app-fefc4501fd27622da1b1.js>; rel=preload; as=script; nopush","Link: </___admin/69bd6bf3-f374cd2e1ee0e375f045.js>; rel=preload; as=script; nopush","Link: </___admin/4c744e84-130bfe682cbb8896de3a.js>; rel=preload; as=script; nopush","Link: </___admin/e2852b4470dcb2615e49edcd9de2a3c8119d4bec-e8377efa018b5b632652.js>; rel=preload; as=script; nopush","Link: </___admin/c432bec7e9afb3443fd639df9e5f119e13575cf7-52c66354c9e40dafee82.js>; rel=preload; as=script; nopush","Link: </___admin/784b2cee55c07b638f20445dec340adf9f1888a3-ff699326697a9b0f1141.js>; rel=preload; as=script; nopush","Link: </___admin/component---src-pages-plugins-tsx-0473a7c3e1abdf54b13c.js>; rel=preload; as=script; nopush","Link: </___admin/page-data/app-data.json>; rel=preload; as=fetch; crossorigin; nopush","Link: </___admin/page-data/plugins/page-data.json>; rel=preload; as=fetch; crossorigin; nopush"],"/___admin/recipe/":["Link: </___admin/webpack-runtime-9172ba536ddfa2136b81.js>; rel=preload; as=script; nopush","Link: </___admin/framework-b24cde22b86a9930317b.js>; rel=preload; as=script; nopush","Link: </___admin/app-fefc4501fd27622da1b1.js>; rel=preload; as=script; nopush","Link: </___admin/69bd6bf3-f374cd2e1ee0e375f045.js>; rel=preload; as=script; nopush","Link: </___admin/854a7ef1f34af0aefbdfdd9304a0c00251662775-aa0380a0e650c4e20230.js>; rel=preload; as=script; nopush","Link: </___admin/784b2cee55c07b638f20445dec340adf9f1888a3-ff699326697a9b0f1141.js>; rel=preload; as=script; nopush","Link: </___admin/component---src-pages-recipe-js-cb2967f252bd2a91f542.js>; rel=preload; as=script; nopush","Link: </___admin/page-data/app-data.json>; rel=preload; as=fetch; crossorigin; nopush","Link: </___admin/page-data/recipe/page-data.json>; rel=preload; as=fetch; crossorigin; nopush"],"/___admin/recipes/":["Link: </___admin/webpack-runtime-9172ba536ddfa2136b81.js>; rel=preload; as=script; nopush","Link: </___admin/framework-b24cde22b86a9930317b.js>; rel=preload; as=script; nopush","Link: </___admin/app-fefc4501fd27622da1b1.js>; rel=preload; as=script; nopush","Link: </___admin/component---src-pages-recipes-tsx-d2dfd910c146829d70ac.js>; rel=preload; as=script; nopush","Link: </___admin/page-data/app-data.json>; rel=preload; as=fetch; crossorigin; nopush","Link: </___admin/page-data/recipes/page-data.json>; rel=preload; as=fetch; crossorigin; nopush"]}
|