Comparing version 5.13.5 to 5.13.6
import type { IHeader } from "../../redux/types"; | ||
type Headers = IHeader["headers"]; | ||
export declare const createHeadersMatcher: (headers: Array<IHeader> | undefined) => (path: string, defaultHeaders: { | ||
export declare const createHeadersMatcher: (headers: Array<IHeader> | undefined, pathPrefix: string) => (path: string, defaultHeaders: { | ||
key: string; | ||
@@ -5,0 +5,0 @@ value: string; |
@@ -9,3 +9,10 @@ "use strict"; | ||
const normalizePath = input => input.endsWith(`/`) ? input : `${input}/`; | ||
const createHeadersMatcher = headers => { | ||
const createHeadersMatcher = (headers, pathPrefix) => { | ||
function stripPathPrefix(path) { | ||
if (pathPrefix && path.startsWith(pathPrefix)) { | ||
path = path.slice(pathPrefix.length); | ||
} | ||
return path; | ||
} | ||
// Split the incoming user headers into two buckets: | ||
@@ -23,11 +30,16 @@ // - dynamicHeaders: Headers with dynamic paths (e.g. /* or /:tests) | ||
for (const header of headers) { | ||
if (header.source.includes(`:`) || header.source.includes(`*`)) { | ||
const source = stripPathPrefix(header.source); | ||
if (source.includes(`:`) || source.includes(`*`)) { | ||
// rankRoute is the internal function that also "match" uses | ||
const score = (0, _rankRoute.rankRoute)(header.source); | ||
const score = (0, _rankRoute.rankRoute)(source); | ||
dynamicHeaders.push({ | ||
...header, | ||
score | ||
score, | ||
source | ||
}); | ||
} else { | ||
staticHeaders.set(normalizePath(header.source), header); | ||
staticHeaders.set(normalizePath(source), { | ||
...header, | ||
source | ||
}); | ||
} | ||
@@ -46,2 +58,4 @@ } | ||
return (path, defaultHeaders) => { | ||
path = stripPathPrefix(path); | ||
// Create a map of headers for the given path | ||
@@ -48,0 +62,0 @@ // The key will be the header key. Since a key may only appear once in a map, the last header with the same key will win |
@@ -274,4 +274,4 @@ "use strict"; | ||
const state = _redux.store.getState(); | ||
const createHeaders = (0, _createHeaders.createHeadersMatcher)(state.config.headers); | ||
const pathPrefix = state.program.prefixPaths ? (_state$config$pathPre = state.config.pathPrefix) !== null && _state$config$pathPre !== void 0 ? _state$config$pathPre : `` : ``; | ||
const createHeaders = (0, _createHeaders.createHeadersMatcher)(state.config.headers, pathPrefix); | ||
const headerRoutes = [...getDefaultHeaderRoutes(pathPrefix)]; | ||
@@ -278,0 +278,0 @@ const fileAssets = new Set((0, _glob.sync)(`**/**`, { |
@@ -175,2 +175,3 @@ "use strict"; | ||
GATSBY_SLICES_SCRIPT: JSON.stringify("5" === `5` && process.env.GATSBY_SLICES ? fs.readFileSync(path.join(rootDir, `public`, `_gatsby`, `slices`, `_gatsby-scripts-1.html`), `utf-8`) : ``), | ||
PATH_PREFIX: JSON.stringify(pathPrefix), | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
@@ -177,0 +178,0 @@ "process.env.GATSBY_LOGGER": JSON.stringify(`yurnalist`), |
@@ -35,2 +35,3 @@ import "../engines-fs-provider"; | ||
const GATSBY_PAGES: Array<[string, EnginePage]>; | ||
const PATH_PREFIX: string; | ||
} | ||
@@ -37,0 +38,0 @@ interface IGetDataBaseArgs { |
@@ -26,3 +26,3 @@ "use strict"; | ||
const tracerReadyPromise = (0, _tracer.initTracer)((_process$env$GATSBY_O = process.env.GATSBY_OPEN_TRACING_CONFIG_FILE) !== null && _process$env$GATSBY_O !== void 0 ? _process$env$GATSBY_O : ``); | ||
const createHeaders = (0, _createHeaders.createHeadersMatcher)(INLINED_HEADERS_CONFIG); | ||
const createHeaders = (0, _createHeaders.createHeadersMatcher)(INLINED_HEADERS_CONFIG, PATH_PREFIX); | ||
function isEagerGraphqlEngine(arg) { | ||
@@ -29,0 +29,0 @@ return typeof arg.graphqlEngine !== `undefined`; |
{ | ||
"name": "gatsby", | ||
"description": "Blazing fast modern site generator for React", | ||
"version": "5.13.5", | ||
"version": "5.13.6", | ||
"author": "Kyle Mathews <mathews.kyle@gmail.com>", | ||
@@ -282,3 +282,3 @@ "bin": { | ||
}, | ||
"gitHead": "6c633505f4e2930119af6e7a442050cae52da9e7" | ||
"gitHead": "36f23d258f63ffa5506bc4e8e0a917fd70721252" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7005344
70742