@cmssy/astro 11.1.0 → 11.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -19,7 +19,9 @@ function cmssyMiddleware(config, options = {}) {
19
19
  if (verified && !pathname.startsWith(CMSSY_EDIT_PATH_PREFIX)) {
20
20
  context.request.headers.set(core.CMSSY_EDIT_HEADER, "1");
21
21
  const target = `${CMSSY_EDIT_PATH_PREFIX}${pathname === "/" ? "" : pathname}${context.url.search}`;
22
- const response = await context.rewrite(target);
22
+ const response = await context.rewrite(
23
+ new Request(new URL(target, context.url), context.request)
24
+ );
23
25
  core.applyCmssyCsp(response, { editorOrigin: config.editorOrigin });
24
26
  return response;
25
27
  }
@@ -49,7 +51,7 @@ function cmssyMiddleware(config, options = {}) {
49
51
  };
50
52
  }
51
53
  async function loadCmssyPage(config, request, url, options = {}) {
52
- const isEdit = request.headers.get(core.CMSSY_EDIT_HEADER) === "1";
54
+ const isEdit = request.headers.get(core.CMSSY_EDIT_HEADER) === "1" || await core.isVerifiedEditUrl(url, config);
53
55
  const segments = url.pathname.replace(/^\/cmssy-edit/, "").split("/").filter(Boolean);
54
56
  const positions = options.positions ?? ["header", "footer"];
55
57
  const blocks = options.blocks ?? [];
package/dist/index.d.cts CHANGED
@@ -14,7 +14,7 @@ interface CmssyMiddlewareOptions {
14
14
  interface AstroContextLike {
15
15
  url: URL;
16
16
  request: Request;
17
- rewrite: (path: string) => Promise<Response> | Response;
17
+ rewrite: (target: string | URL | Request) => Promise<Response> | Response;
18
18
  }
19
19
  /**
20
20
  * The whole middleware a cmssy Astro app needs, in the order it has to happen:
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ interface CmssyMiddlewareOptions {
14
14
  interface AstroContextLike {
15
15
  url: URL;
16
16
  request: Request;
17
- rewrite: (path: string) => Promise<Response> | Response;
17
+ rewrite: (target: string | URL | Request) => Promise<Response> | Response;
18
18
  }
19
19
  /**
20
20
  * The whole middleware a cmssy Astro app needs, in the order it has to happen:
package/dist/index.js CHANGED
@@ -18,7 +18,9 @@ function cmssyMiddleware(config, options = {}) {
18
18
  if (verified && !pathname.startsWith(CMSSY_EDIT_PATH_PREFIX)) {
19
19
  context.request.headers.set(CMSSY_EDIT_HEADER, "1");
20
20
  const target = `${CMSSY_EDIT_PATH_PREFIX}${pathname === "/" ? "" : pathname}${context.url.search}`;
21
- const response = await context.rewrite(target);
21
+ const response = await context.rewrite(
22
+ new Request(new URL(target, context.url), context.request)
23
+ );
22
24
  applyCmssyCsp(response, { editorOrigin: config.editorOrigin });
23
25
  return response;
24
26
  }
@@ -48,7 +50,7 @@ function cmssyMiddleware(config, options = {}) {
48
50
  };
49
51
  }
50
52
  async function loadCmssyPage(config, request, url, options = {}) {
51
- const isEdit = request.headers.get(CMSSY_EDIT_HEADER) === "1";
53
+ const isEdit = request.headers.get(CMSSY_EDIT_HEADER) === "1" || await isVerifiedEditUrl(url, config);
52
54
  const segments = url.pathname.replace(/^\/cmssy-edit/, "").split("/").filter(Boolean);
53
55
  const positions = options.positions ?? ["header", "footer"];
54
56
  const blocks = options.blocks ?? [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/astro",
3
- "version": "11.1.0",
3
+ "version": "11.2.0",
4
4
  "description": "Astro bindings for cmssy headless sites: middleware, page loader, sitemap and robots.",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -40,17 +40,17 @@
40
40
  ],
41
41
  "peerDependencies": {
42
42
  "astro": ">=4",
43
- "@cmssy/react": "^11.1.0"
43
+ "@cmssy/react": "^11.2.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "^20.0.0",
47
47
  "tsup": "^8.3.0",
48
48
  "typescript": "^5.6.0",
49
49
  "vitest": "^2.1.0",
50
- "@cmssy/react": "11.1.0"
50
+ "@cmssy/react": "11.2.0"
51
51
  },
52
52
  "dependencies": {
53
- "@cmssy/core": "11.1.0"
53
+ "@cmssy/core": "11.2.0"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "tsup",