get-route-from-entrypoint.js 1.1 KB

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = getRouteFromEntrypoint;
  6. var _getAppRouteFromEntrypoint = _interopRequireDefault(require("./get-app-route-from-entrypoint"));
  7. var _matchBundle = _interopRequireDefault(require("./match-bundle"));
  8. function getRouteFromEntrypoint(entryFile, app) {
  9. let pagePath = (0, _matchBundle).default(SERVER_ROUTE_NAME_REGEX, entryFile);
  10. if (pagePath) {
  11. return pagePath;
  12. }
  13. if (app) {
  14. pagePath = (0, _getAppRouteFromEntrypoint).default(entryFile);
  15. if (pagePath) return pagePath;
  16. }
  17. // Potentially the passed item is a browser bundle so we try to match that also
  18. return (0, _matchBundle).default(BROWSER_ROUTE_NAME_REGEX, entryFile);
  19. }
  20. function _interopRequireDefault(obj) {
  21. return obj && obj.__esModule ? obj : {
  22. default: obj
  23. };
  24. }
  25. // matches pages/:page*.js
  26. const SERVER_ROUTE_NAME_REGEX = /^pages[/\\](.*)$/;
  27. // matches static/pages/:page*.js
  28. const BROWSER_ROUTE_NAME_REGEX = /^static[/\\]pages[/\\](.*)$/;
  29. //# sourceMappingURL=get-route-from-entrypoint.js.map