Skip to content

Commit dd3b3c6

Browse files
committed
Derive callback footer link labels from branding constants
The URLs lived in branding.ts while their display text stayed inline in the page template, so a rename would have had to touch both. Add matching label constants and restore the no-external-assets guard to its full strength by stripping the two intentional footer links before asserting no other off-machine URL or network call appears.
1 parent 31117fe commit dd3b3c6

3 files changed

Lines changed: 29 additions & 11 deletions

File tree

src/auth/callback-page.test.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { describe, expect, test } from "bun:test";
22

3+
import {
4+
PRODUCT_GITHUB_LABEL,
5+
PRODUCT_GITHUB_URL,
6+
PRODUCT_SITE_LABEL,
7+
PRODUCT_SITE_URL,
8+
} from "../branding.js";
39
import { callbackPageHtml, humanizeIdentifier } from "./callback-page.js";
410

511
describe("humanizeIdentifier", () => {
@@ -42,19 +48,26 @@ describe("callbackPageHtml", () => {
4248
);
4349
});
4450

45-
test("success footer links to corbits.dev and the GitHub org", () => {
51+
test("the footer links to the product site and the GitHub org", () => {
4652
const html = callbackPageHtml({ subject: "linear" });
47-
expect(html).toContain('href="https://corbits.dev"');
48-
expect(html).toContain('href="https://github.com/corbitsdev"');
49-
expect(html).toContain(">corbits.dev<");
50-
expect(html).toContain(">github.com/corbitsdev<");
53+
expect(html).toContain(
54+
`<a href="${PRODUCT_SITE_URL}">${PRODUCT_SITE_LABEL}</a>`,
55+
);
56+
expect(html).toContain(
57+
`<a href="${PRODUCT_GITHUB_URL}">${PRODUCT_GITHUB_LABEL}</a>`,
58+
);
5159
});
5260

5361
test("the page loads no off-machine assets", () => {
5462
const html = callbackPageHtml({ subject: "linear" });
55-
// Product links in the footer are intentional; nothing else may fetch.
56-
expect(html).not.toMatch(/<(?:link|script)\b[^>]+\bsrc=/i);
57-
expect(html).not.toMatch(/@import\b/);
58-
expect(html).not.toMatch(/url\(\s*["']?https?:/i);
63+
// Strip the two intentional footer links, then the page must contain no
64+
// other reference to an off-machine URL: no stylesheet/script/image/frame
65+
// src or href, no CSS @import or url(), and no script-body network call.
66+
const withoutFooterLinks = html.replace(
67+
/<a href="https:\/\/[^"]+">[^<]*<\/a>/g,
68+
"",
69+
);
70+
expect(withoutFooterLinks).not.toMatch(/https?:\/\/(?!www\.w3\.org)/);
71+
expect(html).not.toMatch(/\b(?:fetch|XMLHttpRequest|WebSocket|sendBeacon)\s*\(/);
5972
});
6073
});

src/auth/callback-page.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
*/
1616

1717
import {
18+
PRODUCT_GITHUB_LABEL,
1819
PRODUCT_GITHUB_URL,
1920
PRODUCT_NAME,
21+
PRODUCT_SITE_LABEL,
2022
PRODUCT_SITE_URL,
2123
} from "../branding.js";
2224

@@ -292,7 +294,7 @@ export function callbackPageHtml(page: CallbackPage = {}): string {
292294
`<h1>${heading}</h1>`,
293295
`<p class="body">${body}</p>`,
294296
"<hr>",
295-
`<footer>${PRODUCT_NAME}<span class="sep" aria-hidden="true">·</span><a href="${PRODUCT_SITE_URL}">corbits.dev</a><span class="sep" aria-hidden="true">·</span><a href="${PRODUCT_GITHUB_URL}">github.com/corbitsdev</a></footer>`,
297+
`<footer>${PRODUCT_NAME}<span class="sep" aria-hidden="true">·</span><a href="${PRODUCT_SITE_URL}">${PRODUCT_SITE_LABEL}</a><span class="sep" aria-hidden="true">·</span><a href="${PRODUCT_GITHUB_URL}">${PRODUCT_GITHUB_LABEL}</a></footer>`,
296298
"</div>",
297299
"</main></body>",
298300
`<script>${SCRIPT}</script>`,

src/branding.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ export const PRODUCT_NAME = "Corbits Code";
1111
// Short attribution form used in compact UI (status lines, footers).
1212
export const PRODUCT_SHORT_NAME = "Corbits";
1313

14-
// Canonical public URLs shown on the OAuth callback page and other brand surfaces.
14+
// Canonical public URLs, with the display text that accompanies each, so a link
15+
// and its label cannot drift apart when a domain or org name changes.
1516
export const PRODUCT_SITE_URL = "https://corbits.dev";
17+
export const PRODUCT_SITE_LABEL = "corbits.dev";
1618
export const PRODUCT_GITHUB_URL = "https://github.com/corbitsdev";
19+
export const PRODUCT_GITHUB_LABEL = "github.com/corbitsdev";
1720

1821
export const COMMAND_NAME = "corbits";
1922

0 commit comments

Comments
 (0)