Initial commit
This commit is contained in:
commit
78f8d225ee
21173 changed files with 2907774 additions and 0 deletions
33
node_modules/next/dist/esm/server/lib/router-utils/build-data-route.js
generated
vendored
Normal file
33
node_modules/next/dist/esm/server/lib/router-utils/build-data-route.js
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import path from '../../../shared/lib/isomorphic/path';
|
||||
import { normalizePagePath } from '../../../shared/lib/page-path/normalize-page-path';
|
||||
import { isDynamicRoute } from '../../../shared/lib/router/utils/is-dynamic';
|
||||
import { getNamedRouteRegex } from '../../../shared/lib/router/utils/route-regex';
|
||||
import { normalizeRouteRegex } from '../../../lib/load-custom-routes';
|
||||
import { escapeStringRegexp } from '../../../shared/lib/escape-regexp';
|
||||
export function buildDataRoute(page, buildId) {
|
||||
const pagePath = normalizePagePath(page);
|
||||
const dataRoute = path.posix.join('/_next/data', buildId, `${pagePath}.json`);
|
||||
let dataRouteRegex;
|
||||
let namedDataRouteRegex;
|
||||
let routeKeys;
|
||||
if (isDynamicRoute(page)) {
|
||||
const routeRegex = getNamedRouteRegex(dataRoute, {
|
||||
prefixRouteKeys: true,
|
||||
includeSuffix: true,
|
||||
excludeOptionalTrailingSlash: true
|
||||
});
|
||||
dataRouteRegex = normalizeRouteRegex(routeRegex.re.source);
|
||||
namedDataRouteRegex = routeRegex.namedRegex;
|
||||
routeKeys = routeRegex.routeKeys;
|
||||
} else {
|
||||
dataRouteRegex = normalizeRouteRegex(new RegExp(`^${path.posix.join('/_next/data', escapeStringRegexp(buildId), `${pagePath}\\.json`)}$`).source);
|
||||
}
|
||||
return {
|
||||
page,
|
||||
routeKeys,
|
||||
dataRouteRegex,
|
||||
namedDataRouteRegex
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=build-data-route.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue