@decocms/blocks 7.77.11 → 7.77.13
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/package.json +1 -1
- package/src/cms/blockSource.ts +11 -2
- package/src/cms/renderJson.test.ts +190 -17
- package/src/cms/renderJson.ts +112 -13
- package/src/cms/sectionLoaders.test.ts +118 -0
- package/src/cms/sectionLoaders.ts +126 -67
- package/src/sdk/index.ts +1 -0
- package/src/sdk/redirects.legacy.test.ts +164 -0
- package/src/sdk/redirects.test.ts +328 -0
- package/src/sdk/redirects.ts +384 -79
- package/src/sdk/splitExactRedirects.test.ts +9 -7
|
@@ -27,8 +27,8 @@ describe("splitExactRedirects", () => {
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
expect(exact).toEqual([
|
|
30
|
-
{ path: "/old", to: "/new", status: 301 },
|
|
31
|
-
{ path: "/tmp", to: "/other", status:
|
|
30
|
+
{ path: "/old", from: "/old", to: "/new", status: 301 },
|
|
31
|
+
{ path: "/tmp", from: "/tmp", to: "/other", status: 307 },
|
|
32
32
|
]);
|
|
33
33
|
// Block had nothing but exact rules ⇒ gone entirely, not an empty husk.
|
|
34
34
|
expect(blocks.r).toBeUndefined();
|
|
@@ -71,9 +71,9 @@ describe("splitExactRedirects", () => {
|
|
|
71
71
|
redirect: { from: "https://site.com/Old/", to: "/new" },
|
|
72
72
|
},
|
|
73
73
|
});
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
expect(exact).toEqual([{ path: "/old", to: "/new", status:
|
|
74
|
+
// Folded key (the request-time lookup produces the same byte for byte, in
|
|
75
|
+
// either semantics); the source as written rides along for `"fresh"`.
|
|
76
|
+
expect(exact).toEqual([{ path: "/old", from: "/Old/", to: "/new", status: 307 }]);
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
it("drops the singular `redirect` field when rebuilding a block", () => {
|
|
@@ -99,7 +99,9 @@ describe("splitExactRedirects", () => {
|
|
|
99
99
|
a: { __resolveType: "website/loaders/redirects.ts", redirects: [{ from: "/x", to: "/1" }] },
|
|
100
100
|
b: { __resolveType: "website/loaders/redirects.ts", redirects: [{ from: "/x", to: "/2" }] },
|
|
101
101
|
};
|
|
102
|
-
expect(splitExactRedirects(input).exact).toEqual([
|
|
102
|
+
expect(splitExactRedirects(input).exact).toEqual([
|
|
103
|
+
{ path: "/x", from: "/x", to: "/2", status: 307 },
|
|
104
|
+
]);
|
|
103
105
|
expect(loadRedirects(input).exact.get("/x")?.to).toBe("/2");
|
|
104
106
|
});
|
|
105
107
|
|
|
@@ -120,7 +122,7 @@ describe("splitExactRedirects", () => {
|
|
|
120
122
|
// Exact left the decofile...
|
|
121
123
|
expect(matchRedirect("/a", after)).toBeNull();
|
|
122
124
|
// ...into the extracted list, unchanged.
|
|
123
|
-
expect(exact).toContainEqual({ path: "/a", to: "/1", status: 301 });
|
|
125
|
+
expect(exact).toContainEqual({ path: "/a", from: "/a", to: "/1", status: 301 });
|
|
124
126
|
// Globs still match exactly as before.
|
|
125
127
|
expect(matchRedirect("/b/deep", after)).toEqual(matchRedirect("/b/deep", before));
|
|
126
128
|
});
|