Public: anyone can read this; the crew can change it.
Look pages: a Looks: line can name a look that has a query (/boards?help, /preview-admin/sample/next?pick) #15963
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/15962-look-pages-a-looks-line-can-name-a-look → main 0 commits fork
2 files
changed +3
−2
src/checks/look_pages.ts +2 −2
| @@ -23,12 +23,12 @@ const ROOTS = ["src/http", "src/web", "src/tui"]; | ||
| 23 | 23 | const MAX_SOURCES = 3000; |
| 24 | 24 | const MAX = 1000; |
| 25 | 25 | |
| 26 | /** The pages `forge.json` pictures: plain paths only, anything else is dropped. */ | |
| 26 | /** The pages `forge.json` pictures: plain paths with an optional short query, anything else is dropped. */ | |
| 27 | 27 | export function looksOf(forgeJson: string | undefined): string[] { |
| 28 | 28 | try { |
| 29 | 29 | const looks: unknown = JSON.parse(forgeJson ?? "")?.app?.looks; |
| 30 | 30 | if (!Array.isArray(looks)) return []; |
| 31 | return looks.filter((p): p is string => typeof p === "string" && /^\/[\w\-./:]{0,200}$/.test(p)); | |
| 31 | return looks.filter((p): p is string => typeof p === "string" && /^\/[\w\-./:]{0,200}(\?[\w\-.=&]{1,100})?$/.test(p)); | |
| 32 | 32 | } catch { |
| 33 | 33 | return []; |
| 34 | 34 | } |
test/look-pages-comment.test.ts +1
| @@ -91,6 +91,7 @@ afterAll(async () => { | ||
| 91 | 91 | |
| 92 | 92 | test("forge.json's looks are plain paths only", () => { |
| 93 | 93 | expect(looksOf(`{"app":{"looks":["/", "/a/b", "javascript:x", 3, "/x y"]}}`)).toEqual(["/", "/a/b"]); |
| 94 | expect(looksOf(`{"app":{"looks":["/boards?help", "/a/next?pick=1&b=2", "/x?a b", "/x?<s>", "/x?", "/x?${"a".repeat(101)}"]}}`)).toEqual(["/boards?help", "/a/next?pick=1&b=2"]); | |
| 94 | 95 | expect(looksOf("not json")).toEqual([]); |
| 95 | 96 | expect(looksOf(undefined)).toEqual([]); |
| 96 | 97 | }); |
new above
offline