bpms_site/.svn/pristine/a5/a54d4d8285af09211627270a525872e3829d43fe.svn-base
2025-11-02 16:38:49 +03:30

20 lines
794 B
Plaintext

import getAppRouteFromEntrypoint from "./get-app-route-from-entrypoint";
import matchBundle from "./match-bundle";
// matches pages/:page*.js
const SERVER_ROUTE_NAME_REGEX = /^pages[/\\](.*)$/;
// matches static/pages/:page*.js
const BROWSER_ROUTE_NAME_REGEX = /^static[/\\]pages[/\\](.*)$/;
export default function getRouteFromEntrypoint(entryFile, app) {
let pagePath = matchBundle(SERVER_ROUTE_NAME_REGEX, entryFile);
if (pagePath) {
return pagePath;
}
if (app) {
pagePath = getAppRouteFromEntrypoint(entryFile);
if (pagePath) return pagePath;
}
// Potentially the passed item is a browser bundle so we try to match that also
return matchBundle(BROWSER_ROUTE_NAME_REGEX, entryFile);
}
//# sourceMappingURL=get-route-from-entrypoint.js.map