This commit is contained in:
tamakyi
2026-10-19 16:16:07 +08:00
parent e9fba8b9ed
commit 3202ef9821
54 changed files with 12000 additions and 75 deletions
+30
View File
@@ -0,0 +1,30 @@
package context
import "testing"
// 主题作用域:/user 后台必须命中(否则设置页、题目管理页拿不到自己的主题),
// 其余路径不得命中(提问箱页面由 question.Pager 按箱主注入,公开页保持站点默认)。
func TestIsThemeScope(t *testing.T) {
cases := map[string]bool{
"/user": true,
"/user/": true,
"/user/profile": true,
"/user/questions": true,
"/user/votes/1/results": true,
"/username": false, // 前缀相近但不是用户后台
"/_/admin6": false,
"/_/admin6/share-card": false,
"/": false,
"/explore": false,
"/vote/abc": false,
"/api/v1/user/admin6": false,
"/api/v1/user": false,
"/deactivated": false,
}
for path, want := range cases {
if got := isThemeScope(path); got != want {
t.Errorf("isThemeScope(%q) = %v, want %v", path, got, want)
}
}
}