From 73af568c3f0bafeb18cf610b8d953cc42a4a4304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=85=E5=BF=B5?= Date: Fri, 18 Sep 2026 09:55:29 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20define=E9=94=AE=E6=94=B9=E7=82=B9?= =?UTF-8?q?=E9=93=BE=E5=BD=A2=E5=BC=8F=EF=BC=88esbuild=E6=88=90=E5=91=98?= =?UTF-8?q?=E8=A1=A8=E8=BE=BE=E5=BC=8F=E6=9B=BF=E6=8D=A2=E5=AE=9E=E6=B5=8B?= =?UTF-8?q?=E7=BA=A6=E6=9D=9F=EF=BC=89+spec=E5=90=8C=E6=AD=A5slug=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E7=BA=BF32=E5=8F=A3=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Code --- .../2026-09-18-collection-foundation-phase-a.md | 14 ++++++++------ ...6-09-18-collection-foundation-phase-a-design.md | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/superpowers/plans/2026-09-18-collection-foundation-phase-a.md b/docs/superpowers/plans/2026-09-18-collection-foundation-phase-a.md index ac548b9..5ccb5b3 100644 --- a/docs/superpowers/plans/2026-09-18-collection-foundation-phase-a.md +++ b/docs/superpowers/plans/2026-09-18-collection-foundation-phase-a.md @@ -80,8 +80,8 @@ Expected: FAIL(`SANITIZE_RULE_VERSION` 不存在 / userinfo 未剥离) ```python SANITIZE_RULE_VERSION = "v2" -# 三轨制(spec §2.4):①参数名黑名单整键删;②归因白名单提取保留; -# ③其余参数按值判别:安全模式(纯数字≤10位 / slug≤64)保留,其余删。 +# 三轨制(spec §2.4,slug 安全线以本计划为准=32):①参数名黑名单整键删; +# ②归因白名单提取保留;③其余按值判别:纯数字≤10位或 slug≤32 保留,其余删。 URL_PARAM_DROP_PATTERNS = ("email", "phone", "mobile", "tel", "name", "user", "token", "key", "password", "verif", "passwd", "idcard") ATTRIBUTION_PARAM_WHITELIST = {"gclid", "gbraid", "wbraid", "fbclid", "msclkid", @@ -363,16 +363,18 @@ import { execSync } from "node:child_process"; const buildId = execSync("git log -1 --format=%h-%cd --date=format:%Y%m%d%H%M").toString().trim(); await build({ entryPoints: ["src/index.ts"], bundle: true, minify: true, format: "iife", outfile: "dist/v1.js", target: ["es2020"], - define: { __BUILD_ID__: JSON.stringify(buildId) } }); + // define 键必须用点链:esbuild 只做精确表达式匹配,裸键 __BUILD_ID__ + // 不会替换 globalThis.__BUILD_ID__ 成员访问(实测 0.24.2),build_id 将恒为 "unknown" + define: { "globalThis.__BUILD_ID__": JSON.stringify(buildId) } }); ``` (fallback:git 失败时用 `"dev-" + Date.now()`,try/catch 包裹——构建环境无 git 不得挂。) -vitest.config.ts 同步注入(否则 index.ts 引用 BUILD_ID 在测试环境 undefined——有 ?? 兜底不炸,但注入后可断言真实值): +vitest.config.ts 同步注入(键同样用点链): ```ts export default defineConfig({ - define: { __BUILD_ID__: JSON.stringify("vitest") }, + define: { "globalThis.__BUILD_ID__": JSON.stringify("vitest") }, test: { environment: "happy-dom" }, }); ``` @@ -504,7 +506,7 @@ test("v1 兼容形态不再产生(新 SDK 恒 schema_version:2 信封 + 事件 ```ts import vectors from "../../server/tracker/tests/fixtures/sanitize_vectors.json"; -test.each(vectors.vectors)("sanitizeUrl($input) → $expected", (v) => { +test.each(vectors.vectors)("sanitizeUrl vector", (v) => { expect(sanitizeUrl(v.in)).toBe(v.out); }); ``` diff --git a/docs/superpowers/specs/2026-09-18-collection-foundation-phase-a-design.md b/docs/superpowers/specs/2026-09-18-collection-foundation-phase-a-design.md index 2c7715a..c056720 100644 --- a/docs/superpowers/specs/2026-09-18-collection-foundation-phase-a-design.md +++ b/docs/superpowers/specs/2026-09-18-collection-foundation-phase-a-design.md @@ -102,7 +102,7 @@ URL 清洗三轨制(替代现行"仅参数名黑名单"): 1. **参数名黑名单**(phone/mobile/tel/email/name/user/token/key/password/verif 等)→ 删; 2. **归因白名单**(utm_*、gclid、gbraid、wbraid、fbclid、gad_source、gad_campaignid、msclkid 等)→ 提取保留(供归因); -3. **其余参数按值判别**:含 @、超 32 位随机串、超长值 → 删;纯数字 ≤10 位、短 slug(≤64 字母数字连字符)→ 保留(未知业务参数如 ?id=123 自动保住,WordPress query 路由不受影响)。 +3. **其余参数按值判别**:含 @、超 32 位随机串、超长值 → 删;纯数字 ≤10 位、短 slug → 保留(未知业务参数如 ?id=123 自动保住,WordPress query 路由不受影响)。slug 安全线定 **32**(总长 ≤32 且 [A-Za-z0-9._-],32+ 连续字母数字视为 token 删——实现计划已用向量钉死此口径,以计划为准)。 另:URL userinfo 剥离;fragment 全删(hash 路由站点阶段B 前不适配,边界注明);title 中敏感内容按站点模板规则本阶段不做(无规则来源,边界注明)。