Files
Genarrative/src/components/game-distribution/gameDistributionGuards.test.ts
T
kdletters 87e52860a7
Project CI / AI game creator shell Rust crates (push) Successful in 1m26s
Project CI / AI game creator shell Rust smoke (push) Successful in 2m11s
Project CI / Backend tests (push) Successful in 5m12s
Project CI / AI game creator shell Rust lane 2/2 (push) Successful in 8m26s
Project CI / Native shell tests (push) Successful in 6m31s
Project CI / Frontend tests (push) Successful in 2m20s
Project CI / Repository checks (push) Successful in 2m25s
Project CI / AI game creator shell web tests (push) Successful in 1m21s
Project CI / AI game creator shell Rust lane 1/2 (push) Has been cancelled
游戏发行入口改为平台同源路径
- 审核通过时由 api-server 按 gameId 派生 /games/{gameId}/ 相对路径写入公开投影,删除 AppConfig 的发行入口模板字段与读取逻辑
- 删除 deploy/env 两份示例中的 GENARRATIVE_GAME_DISTRIBUTION_RELEASE_ENTRY_TEMPLATE
- 三份 nginx 模板内联同源发行入口 location,把 /games/<gameId>/ 与子资源转发到发行网关并在边缘清空 Cookie
- SPA allowlist 补齐 components、design-system、games、games/detail、games/mine、games/play、games/publish
- 前端 normalizeGameEntryUrl 支持相对路径与同源发行路径,按当前 origin 解析并补尾斜杠,继续兼容历史绝对 URL
- 删除退役的独立来源模板 deploy/nginx/genarrative-release-origin.conf、门禁脚本 scripts/check-release-origin-config.mjs 与其 npm 脚本
- 游戏分发 e2e 脚本改为在公开投影上断言 entryUrl 等于 /games/{gameId}/
- 同步平台主规范、运维主规范、nginx README 与共享决策记录
2026-09-24 00:21:27 +08:00

47 lines
1.4 KiB
TypeScript

/* @vitest-environment jsdom */
import { describe, expect, it } from 'vitest';
import { normalizeGameEntryUrl } from './gameDistributionGuards';
const GAME_ID = `game_${'a'.repeat(32)}`;
const GAME_ENTRY_PATH = `/games/${GAME_ID}/`;
describe('normalizeGameEntryUrl', () => {
it('resolves a release gateway relative path against the current origin', () => {
expect(normalizeGameEntryUrl(GAME_ENTRY_PATH)).toBe(
new URL(GAME_ENTRY_PATH, window.location.origin).href,
);
});
it('adds the trailing slash required for relative game assets', () => {
expect(normalizeGameEntryUrl(`/games/${GAME_ID}`)).toBe(
new URL(GAME_ENTRY_PATH, window.location.origin).href,
);
});
it('normalizes a same-origin absolute release gateway URL', () => {
expect(
normalizeGameEntryUrl(`${window.location.origin}/games/${GAME_ID}`),
).toBe(new URL(GAME_ENTRY_PATH, window.location.origin).href);
});
it.each([
`/games/${GAME_ID}/assets/x.js`,
'/games/detail',
'/creation',
'/',
'javascript:alert(1)',
'https://user:pass@x/y',
'http://evil.test/x',
])('rejects an invalid or unsafe entry URL: %s', (entryUrl) => {
expect(normalizeGameEntryUrl(entryUrl)).toBeNull();
});
it('passes through an absolute HTTPS URL on another origin', () => {
const entryUrl = 'https://play.example.test/releases/version-1/index.html';
expect(normalizeGameEntryUrl(entryUrl)).toBe(entryUrl);
});
});