utils.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.isBlockedPage = isBlockedPage;
  6. exports.cleanAmpPath = cleanAmpPath;
  7. exports.isTargetLikeServerless = isTargetLikeServerless;
  8. exports.shouldUseReactRoot = void 0;
  9. var _react = _interopRequireDefault(require("react"));
  10. var _constants = require("../shared/lib/constants");
  11. function _interopRequireDefault(obj) {
  12. return obj && obj.__esModule ? obj : {
  13. default: obj
  14. };
  15. }
  16. function isBlockedPage(pathname) {
  17. return _constants.BLOCKED_PAGES.includes(pathname);
  18. }
  19. function cleanAmpPath(pathname) {
  20. if (pathname.match(/\?amp=(y|yes|true|1)/)) {
  21. pathname = pathname.replace(/\?amp=(y|yes|true|1)&?/, "?");
  22. }
  23. if (pathname.match(/&amp=(y|yes|true|1)/)) {
  24. pathname = pathname.replace(/&amp=(y|yes|true|1)/, "");
  25. }
  26. pathname = pathname.replace(/\?$/, "");
  27. return pathname;
  28. }
  29. function isTargetLikeServerless(target) {
  30. const isServerless = target === "serverless";
  31. const isServerlessTrace = target === "experimental-serverless-trace";
  32. return isServerless || isServerlessTrace;
  33. }
  34. const shouldUseReactRoot = parseInt(_react.default.version) >= 18;
  35. exports.shouldUseReactRoot = shouldUseReactRoot;
  36. //# sourceMappingURL=utils.js.map