feat(widget): 脚本地址自推导 basePath(路径模式端点前缀)

spec 2026-10-19 §4: 路径模式(/t/<slug>/static/widget.js)下从 script.src
剥尾推导 basePath,brand/avatar 三分支/WS 四处端点构造统一加前缀;
Host 模式 indexOf 命中在 0 → basePath="" 端点零变化。
test_theme_static.py 头像锚定守卫随构造更新(wsBase + basePath + …,
语义不变:绝对锚定 + 禁相对路径)。

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-10-19 18:13:49 +08:00
parent 3862577143
commit 0baa9ab2ed
3 changed files with 50 additions and 6 deletions
+2 -1
View File
@@ -124,7 +124,8 @@ def test_widget_avatar_src_uses_wsbase():
src = _read("widget.js")
assert 'DEFAULT_AVATAR_PATH = "/static/kefu-small.png"' in src
assert 'src="/static/kefu-small.png"' not in src, "挂件禁用相对路径头像(客户站会 404)"
assert "wsBase + DEFAULT_AVATAR_PATH" in src
# spec 2026-10-19 §4: 默认头像同样走 basePath 前缀(Host 模式为空串零变化)
assert "wsBase + basePath + DEFAULT_AVATAR_PATH" in src
def test_style_root_defaults_match_theme_palette():