refactor(*): 平台架构 - 拆分后端领域模块并同步插件协议与模型能力

This commit is contained in:
ddCat committed 2026-09-11 14:02:49 +08:00
1 parent 916043fb5a
commit 6e5cbc8b05
644 files changed
+62731 -2320

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
package assets
import "testing"
func TestIDFromFileURL(t *testing.T) {
cases := []struct {
in string
want string
}{
{"/api/resources/abc_123/file", "abc_123"},
{"https://host.example/api/resources/abc_123/file?proxy=1", "abc_123"},
{"/api/projects/abc_123", ""},
{"", ""},
}
for _, item := range cases {
if got := IDFromFileURL(item.in); got != item.want {
t.Fatalf("IDFromFileURL(%q) = %q, want %q", item.in, got, item.want)
}
}
}
func TestResourceID(t *testing.T) {
if got := ResourceID("resource:abc_123"); got != "abc_123" {
t.Fatalf("ResourceID(resource:) = %q", got)
}
if got := ResourceID("/api/resources/abc_123/file"); got != "abc_123" {
t.Fatalf("ResourceID(file url) = %q", got)
}
if got := ResourceID("resource:../secret"); got != "" {
t.Fatalf("ResourceID accepted traversal: %q", got)
}
}