UNPKG

910 BJavaScriptView Raw
1"use strict";exports.__esModule=true;exports.default=getRouteFromEntrypoint;var _getRouteFromAssetPath=_interopRequireDefault(require("../lib/router/utils/get-route-from-asset-path"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}// matches pages/:page*.js
2const SERVER_ROUTE_NAME_REGEX=/^pages[/\\](.*)$/;// matches static/pages/:page*.js
3const BROWSER_ROUTE_NAME_REGEX=/^static[/\\]pages[/\\](.*)$/;function matchBundle(regex,input){const result=regex.exec(input);if(!result){return null;}return(0,_getRouteFromAssetPath.default)(`/${result[1]}`);}function getRouteFromEntrypoint(entryFile){let pagePath=matchBundle(SERVER_ROUTE_NAME_REGEX,entryFile);if(pagePath){return pagePath;}// Potentially the passed item is a browser bundle so we try to match that also
4return matchBundle(BROWSER_ROUTE_NAME_REGEX,entryFile);}
5//# sourceMappingURL=get-route-from-entrypoint.js.map
\No newline at end of file