Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; | |
| 3 | ||
| 4 | import { CONTACT, POLICIES, copyright, copyrightYear, listed, longDate, securityTxt } from "./legal.ts"; | |
| 5 | ||
| 6 | test("the copyright year is computed, in UTC", () => { | |
| 7 | assert.equal(copyrightYear(new Date("2026-10-05T12:00:00Z")), 2026); | |
| 8 | assert.equal(copyrightYear(new Date("2027-01-01T00:00:00Z")), 2027); | |
| 9 | // Still 31 December in UTC, whatever the server's own zone says. | |
| 10 | assert.equal(copyrightYear(new Date("2026-12-31T23:59:59Z")), 2026); | |
| 11 | }); | |
| 12 | ||
| 13 | test("the legal line names the company and the year", () => { | |
| 14 | assert.equal(copyright(new Date("2026-10-05T00:00:00Z")), "© 2026 Flagon, Inc. All rights reserved."); | |
| 15 | assert.equal(copyright(new Date("2031-03-01T00:00:00Z")), "© 2031 Flagon, Inc. All rights reserved."); | |
| 16 | }); | |
| 17 | ||
| 18 | test("products are listed the way a sentence lists them", () => { | |
| 19 | assert.equal(listed([]), ""); | |
| 20 | assert.equal(listed(["HEY"]), "HEY"); | |
| 21 | assert.equal(listed(["HEY", "Fizzy"]), "HEY and Fizzy"); | |
| 22 | assert.equal(listed(["A", "B", "C"]), "A, B and C"); | |
| 23 | }); | |
| 24 | ||
| 25 | test("policy dates read as words", () => { | |
| 26 | assert.equal(longDate("2026-10-05"), "October 5, 2026"); | |
| 27 | assert.equal(longDate("2027-01-31"), "January 31, 2027"); | |
| 28 | }); | |
| 29 | ||
| 30 | test("every policy has its own address", () => { | |
| 31 | const slugs = POLICIES.map((policy) => policy.slug); | |
| 32 | assert.equal(new Set(slugs).size, slugs.length); | |
| 33 | for (const slug of slugs) assert.match(slug, /^[a-z-]+$/); | |
| 34 | }); | |
| 35 | ||
| 36 | test("security.txt has the fields RFC 9116 asks for, and expires within a year", () => { | |
| 37 | const now = new Date("2026-10-05T15:30:00Z"); | |
| 38 | const text = securityTxt(now); | |
| 39 | assert.ok(text.split("\n").includes(`Contact: mailto:${CONTACT.security}`)); | |
| 40 | assert.match(text, /^Policy: https:\/\/g1t\.sh\/security#responsible-disclosure$/m); | |
| 41 | const expires = /^Expires: (.+)$/m.exec(text)?.[1]; | |
| 42 | assert.ok(expires); | |
| 43 | assert.match(expires, /^\d{4}-\d{2}-\d{2}T00:00:00Z$/); | |
| 44 | const days = (Date.parse(expires) - now.getTime()) / 86_400_000; | |
| 45 | assert.ok(days > 30 && days < 365, `${days} days`); | |
| 46 | assert.ok(text.endsWith("\n")); | |
| 47 | }); |