fix: 修复文件预览重定向与扩展名解析

This commit is contained in:
richjohnrambo
2026-09-09 16:32:49 +08:00
parent cae5039afe
commit 23afc1b7f1
7 changed files with 117 additions and 12 deletions
+26
View File
@@ -0,0 +1,26 @@
//go:build mysql
// +build mysql
package mysql
import (
"testing"
"github.com/tinode/chat/server/store/types"
)
func TestParseFileUIDStripsPublicExtension(t *testing.T) {
uid := types.ParseUid("scH0N8guCHk")
if uid.IsZero() {
t.Fatal("test UID failed to parse")
}
if got := parseFileUID("scH0N8guCHk.bin"); got != uid {
t.Fatalf("parseFileUID()=%q, want %q", got.String(), uid.String())
}
if got := parseFileUID("scH0N8guCHk.jpg"); got != uid {
t.Fatalf("parseFileUID()=%q, want %q", got.String(), uid.String())
}
if got := parseFileUID("scH0N8guCHk"); got != uid {
t.Fatalf("parseFileUID()=%q, want %q", got.String(), uid.String())
}
}