perf(files): 优化私有文件鉴权与高成本查询隔离
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package filekey
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestCanonical(t *testing.T) {
|
||||
tests := map[string]string{
|
||||
"listing/2026/11/a.webp": "listing/2026/11/a.webp",
|
||||
"/api/files/object?key=listing%2F2026%2F11%2Fa.webp": "listing/2026/11/a.webp",
|
||||
"/api/admin/files/object?key=listing/2026/11/a.webp": "listing/2026/11/a.webp",
|
||||
"/api/files/object?key=listing%2F2026%2F11%2Fa.webp.medium.jpg": "listing/2026/11/a.webp",
|
||||
"https://example.com/external.png": "",
|
||||
"../secret": "",
|
||||
}
|
||||
for raw, want := range tests {
|
||||
t.Run(raw, func(t *testing.T) {
|
||||
if got := Canonical(raw); got != want {
|
||||
t.Fatalf("Canonical(%q) = %q, want %q", raw, got, want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user