Skip to content

Commit a3cd8b0

Browse files
TMHSDigitalharshkanhatbfs2021riteshyadav33302111-cellclaude
committed
Fold in the extras from PRs #242, #243 and #244
The fixes these pull requests made had already landed on main, so their branches conflict; these are the parts main did not have: - data.schema.json: list items must be non-empty strings (minLength 1), from #244. schema-check.mjs gains minLength (by character) so the build's own schema check can enforce it. - checks.test.mjs: a preview URL with an unclosed IPv6 bracket, and one carrying credentials, are refused rather than thrown, from #243. - site/README.md: a paragraph on opensearch.xml, from #242. Co-authored-by: harshkanhat <kanhatharsh@gmail.com> Co-authored-by: bfs2021 <101915083+bfs2021@users.noreply.github.com> Co-authored-by: Ritesh Yadav <riteshyadav33302111@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LpkeXQPaUhxjgqdqnk6BrJ
1 parent 48303b9 commit a3cd8b0

5 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎site/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ under `/Free-Game-Dev-Assets/` it is never seen. Submit
153153
`https://tmhsdigital.github.io/Free-Game-Dev-Assets/sitemap.xml` once in Google Search
154154
Console and Bing Webmaster Tools; that is the step that gets it read.
155155

156+
`build.mjs` also writes `opensearch.xml`, an OpenSearch 1.1 description linked from the
157+
homepage with `<link rel="search">`, so a browser can add the catalog as a search engine;
158+
a search opens the homepage with `?q={searchTerms}`.
159+
156160
## Link check
157161

158162
`.github/workflows/links.yml` runs `site/check-links.mjs` every Monday at 07:41 UTC (and

‎site/checks.test.mjs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,8 @@ rejects("preview field: http refused", checkPreviewField("bad.md", { preview: "h
835835
rejects("preview field: loopback refused", checkPreviewField("bad.md", { preview: "https://127.0.0.1/a.png" }), "bad.md preview must be an https:// image URL on a public host");
836836
rejects("preview field: an unparseable https url is refused, not thrown", checkPreviewField("bad.md", { preview: "https://exa%zzmple.com/a.png" }), "bad.md preview must be an https:// image URL on a public host");
837837
rejects("preview field: bad port refused", checkPreviewField("bad.md", { preview: "https://a.test:99999/x.png" }), "bad.md preview must be an https:// image URL on a public host");
838+
rejects("preview field: an unclosed IPv6 bracket is refused, not thrown", checkPreviewField("bad.md", { preview: "https://[bad" }), "bad.md preview must be an https:// image URL on a public host");
839+
rejects("preview field: credentials in the URL refused", checkPreviewField("bad.md", { preview: "https://u:p@a.example/b.png" }), "bad.md preview must be an https:// image URL on a public host");
838840
rejects("preview field: word refused", checkPreviewField("bad.md", { preview: "yes" }), 'bad.md preview must be "none" or an https:// image URL');
839841

840842
/* V30: line endings ------------------------------------------------------ */

‎site/data.schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
}
8282
},
8383
"$defs": {
84-
"stringList": { "type": "array", "items": { "type": "string" } },
84+
"stringList": { "type": "array", "items": { "type": "string", "minLength": 1 } },
8585
"entryBase": {
8686
"type": "object",
8787
"required": [

‎site/lib/lib.test.mjs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,10 @@ eq("search: q from the URL is capped", readState(`?q=${"a".repeat(5000)}`, { q:
15301530
/* data.json schema (schema-check.mjs + site/data.schema.json) -------------- */
15311531
{
15321532
const { schemaErrors } = await import("./schema-check.mjs");
1533+
// minLength (from #244): an empty list item in data.json is a schema error.
1534+
has("schema: minLength refuses an empty string", schemaErrors({ type: "string", minLength: 1 }, "").join(), 'is shorter than 1');
1535+
eq("schema: minLength accepts a long enough string", schemaErrors({ type: "string", minLength: 1 }, "a").length, 0);
1536+
eq("schema: minLength counts characters, not UTF-16 units", schemaErrors({ type: "string", minLength: 2 }, "\u{1F600}").length, 1);
15331537
const schema = JSON.parse(nodeFs.readFileSync(new URL("../data.schema.json", import.meta.url), "utf8"));
15341538
const entry = {
15351539
id: "a", name: "A", url: "https://a.example/", category: "2d", subcategories: ["x"], license: "CC0", commercial: true,

‎site/lib/schema-check.mjs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
const KNOWN = new Set([
1212
"$schema", "$id", "$defs", "$ref", "title", "description",
1313
"type", "enum", "required", "properties", "additionalProperties", "unevaluatedProperties",
14-
"items", "pattern", "minimum",
14+
"items", "pattern", "minimum", "minLength",
1515
]);
1616

1717
function typeOf(v) {
@@ -63,6 +63,9 @@ export function schemaErrors(schema, value, { root = schema, path = "$" } = {})
6363
if (typeof value === "string" && schema.pattern && !new RegExp(schema.pattern, "u").test(value)) {
6464
errors.push(`${path}: ${show(value)} does not match ${schema.pattern}`);
6565
}
66+
if (typeof value === "string" && schema.minLength !== undefined && [...value].length < schema.minLength) {
67+
errors.push(`${path}: ${show(value)} is shorter than ${schema.minLength}`);
68+
}
6669
if (typeof value === "number" && schema.minimum !== undefined && value < schema.minimum) {
6770
errors.push(`${path}: ${value} is below ${schema.minimum}`);
6871
}

0 commit comments

Comments
 (0)