@cancia/astro 0.9.0 → 0.10.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/{chunk-GBTFXQEA.js → chunk-NVXNJ4YC.js} +1 -1
- package/dist/{chunk-HQIGNRIU.js → chunk-ONKCUTPU.js} +1 -1
- package/dist/{chunk-WVHTCFE6.js → chunk-YGJ3JHXF.js} +8 -1
- package/dist/content.js +6 -6
- package/dist/endpoints/schemas.js +2 -2
- package/dist/index.js +3 -3
- package/dist/loader/index.js +2 -2
- package/dist/schema/index.js +1 -1
- package/dist/transform/text-helper.js +4 -5
- package/package.json +1 -1
|
@@ -93,7 +93,14 @@ var defineField = {
|
|
|
93
93
|
*/
|
|
94
94
|
link: (o) => z.object({
|
|
95
95
|
label: z.string(),
|
|
96
|
-
href:
|
|
96
|
+
// An EMPTY href is allowed: it means "this link has no destination
|
|
97
|
+
// yet", which is a state the editor must be able to save — otherwise a
|
|
98
|
+
// client cannot clear a URL at all, and the form rejects a field they
|
|
99
|
+
// deliberately emptied. `isSafeHref("")` is false (correct for
|
|
100
|
+
// rendering, where an empty href must not become an anchor), so the
|
|
101
|
+
// empty case is permitted here explicitly rather than by loosening the
|
|
102
|
+
// guard. Anything non-empty still has to pass it.
|
|
103
|
+
href: z.string().refine((h) => h === "" || isSafeHref(h), "unsafe or unsupported URL scheme")
|
|
97
104
|
}).meta({ widget: "link", ...o }),
|
|
98
105
|
/**
|
|
99
106
|
* A constrained rich-text body. Stored as a Portable-Text SUBSET array (D4):
|
package/dist/content.js
CHANGED
|
@@ -20,17 +20,17 @@ function isSafeHref(href) {
|
|
|
20
20
|
return true;
|
|
21
21
|
}
|
|
22
22
|
function parseLink(raw, fallback) {
|
|
23
|
-
if (
|
|
23
|
+
if (raw === void 0) return fallback;
|
|
24
|
+
if (raw === "") return { label: "", href: "" };
|
|
24
25
|
const trimmed = raw.trim();
|
|
25
26
|
if (trimmed.startsWith("{")) {
|
|
26
27
|
try {
|
|
27
28
|
const p = JSON.parse(trimmed);
|
|
28
29
|
if (p && typeof p === "object") {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
30
|
+
const label = p.label === void 0 ? fallback.label : String(p.label);
|
|
31
|
+
const rawHref = p.href === void 0 ? void 0 : String(p.href);
|
|
32
|
+
const href = rawHref === void 0 ? fallback.href : rawHref === "" ? "" : isSafeHref(rawHref) ? rawHref : fallback.href;
|
|
33
|
+
return { label, href };
|
|
34
34
|
}
|
|
35
35
|
} catch {
|
|
36
36
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
makeSchemasRoute
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ONKCUTPU.js";
|
|
4
4
|
import {
|
|
5
5
|
runPublish
|
|
6
6
|
} from "./chunk-5RCLBWRH.js";
|
|
@@ -30,7 +30,7 @@ import "./chunk-U7V53JX7.js";
|
|
|
30
30
|
import "./chunk-VL6FO446.js";
|
|
31
31
|
import {
|
|
32
32
|
canciaLoader
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-NVXNJ4YC.js";
|
|
34
34
|
import {
|
|
35
35
|
createJsonFileAdapter,
|
|
36
36
|
createJsonFileAdapterV2
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
defineList,
|
|
44
44
|
describeList,
|
|
45
45
|
z
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-YGJ3JHXF.js";
|
|
47
47
|
import "./chunk-KHCFVVYV.js";
|
|
48
48
|
|
|
49
49
|
// src/integration.ts
|
package/dist/loader/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
canciaLoader
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-NVXNJ4YC.js";
|
|
4
4
|
import "../chunk-2NVZWZPE.js";
|
|
5
5
|
import "../chunk-7IA5B5CF.js";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-YGJ3JHXF.js";
|
|
7
7
|
import "../chunk-KHCFVVYV.js";
|
|
8
8
|
export {
|
|
9
9
|
canciaLoader
|
package/dist/schema/index.js
CHANGED
|
@@ -44,11 +44,10 @@ function __canciaLink(cms, key, labelFallback, hrefFallback) {
|
|
|
44
44
|
if (trimmed.startsWith("{")) {
|
|
45
45
|
try {
|
|
46
46
|
const parsed = JSON.parse(trimmed);
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
47
|
+
const label = parsed.label === void 0 ? labelFallback : String(parsed.label);
|
|
48
|
+
const rawHref = parsed.href === void 0 ? void 0 : String(parsed.href);
|
|
49
|
+
const href = rawHref === void 0 ? hrefFallback : rawHref === "" ? "" : isSafeHref(rawHref) ? rawHref : hrefFallback;
|
|
50
|
+
return { label, href };
|
|
52
51
|
} catch {
|
|
53
52
|
return fallback;
|
|
54
53
|
}
|