get-route-from-asset-path.js 638 B

123456789101112131415161718
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = getRouteFromAssetPath;
  6. var _isDynamic = require("./is-dynamic");
  7. function getRouteFromAssetPath(assetPath, ext = '') {
  8. assetPath = assetPath.replace(/\\/g, '/');
  9. assetPath = ext && assetPath.endsWith(ext) ? assetPath.slice(0, -ext.length) : assetPath;
  10. if (assetPath.startsWith('/index/') && !(0, _isDynamic).isDynamicRoute(assetPath)) {
  11. assetPath = assetPath.slice(6);
  12. } else if (assetPath === '/index') {
  13. assetPath = '/';
  14. }
  15. return assetPath;
  16. }
  17. //# sourceMappingURL=get-route-from-asset-path.js.map