Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions src/site-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,6 @@ export function sameOriginSiteUrl(currentUrl, value) {
return target.href;
}

export function pixePuzzleNavigationUrl(currentUrl, puzzleKey) {
let current;
try {
current = new URL(String(currentUrl || ""));
} catch {
return "";
}
const key = String(puzzleKey || "");
const validKey = /^L[1-9]\d{0,5}$/.test(key) ||
(/^D\d{4}-\d{2}-\d{2}$/.test(key) &&
!Number.isNaN(Date.parse(key.slice(1))));
if (
current.hostname !== "pixe.frgmt.xyz" ||
current.pathname !== "/" ||
!validKey
) {
return "";
}
return new URL(`/play/${key}`, current).href;
}

export function normalizeSiteHeaders(value) {
if (!isRecord(value)) return {};
const headers = {};
Expand Down
24 changes: 0 additions & 24 deletions tests/node/site-tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import test from "node:test";

import {
normalizeSiteHeaders,
pixePuzzleNavigationUrl,
sameOriginSiteUrl,
siteTextExcerpts,
} from "../../dist/src/site-tools.js";
Expand All @@ -23,29 +22,6 @@ test("site helpers resolve relative URLs but reject cross-origin access", () =>
);
});

test("Pixe puzzle cards use bounded direct routes on the lightweight DOM backend", () => {
assert.equal(
pixePuzzleNavigationUrl("https://pixe.frgmt.xyz/", "L12"),
"https://pixe.frgmt.xyz/play/L12",
);
assert.equal(
pixePuzzleNavigationUrl("https://pixe.frgmt.xyz/", "D2026-08-06"),
"https://pixe.frgmt.xyz/play/D2026-08-06",
);
assert.equal(
pixePuzzleNavigationUrl("https://pixe.frgmt.xyz/play/L1", "L2"),
"",
);
assert.equal(
pixePuzzleNavigationUrl("https://example.com/", "L1"),
"",
);
assert.equal(
pixePuzzleNavigationUrl("https://pixe.frgmt.xyz/", "../admin"),
"",
);
});

test("site.request headers preserve the browser's credential boundary", () => {
assert.deepEqual(normalizeSiteHeaders({ Accept: "application/json" }), {
accept: "application/json",
Expand Down
Loading