Files
MineGeo/tests/desktop.test.ts
pavel444-byte 1f254b29a2
All checks were successful
Deploy MineGeo to Dokploy / deploy (push) Successful in 5m57s
Update MineGeo domain and harden process supervision
2026-10-15 20:35:39 +05:00

34 lines
1.0 KiB
TypeScript

import assert from "node:assert/strict";
import { test } from "node:test";
import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
const { isInternal, isExternal } = require("../desktop/navigation.cjs");
test("desktop navigation confines remote content to the production origin", () => {
assert.equal(isInternal("https://minegeo.site/play?map=1"), true);
for (const url of [
"http://minegeo.site",
"https://minegeo.site.evil.test",
"https://minegeo.site@evil.test",
"file:///C:/Windows",
"javascript:alert(1)",
"not a URL",
]) {
assert.equal(isInternal(url), false, url);
}
});
test("desktop only opens credential-free HTTPS links in external apps", () => {
assert.equal(isExternal("https://discord.com/invite/example"), true);
for (const url of [
"file:///C:/Windows",
"javascript:alert(1)",
"ms-settings:windowsupdate",
"http://example.com",
"https://user:password@example.com",
"not a URL",
]) {
assert.equal(isExternal(url), false, url);
}
});