Files
Mycontent/soul-api/internal/handler/autolink_test.go
Alex-larget f9e352be96 feat: enhance user profile setup for new users
- Introduced a mandatory profile guide for new users to complete their avatar and nickname before proceeding.
- Updated the avatar-nickname page to ensure fields are empty on entry, preventing auto-fill issues.
- Implemented checks to ensure users cannot navigate away without completing their profile.
- Removed deprecated privacy modal handling, streamlining the user experience.
- Adjusted UI elements to indicate required fields for new users.
2026-04-01 16:11:30 +08:00

45 lines
1.0 KiB
Go

package handler
import (
"strings"
"testing"
)
func TestSanitizeLinkTagLabel(t *testing.T) {
cases := []struct {
in, want string
}{
{"碎片时间」。", "碎片时间"},
{"碎片时间」小", "碎片时间」小"},
{"碎片时间", "碎片时间"},
}
for _, c := range cases {
got := sanitizeLinkTagLabel(c.in)
if got != c.want {
t.Errorf("sanitizeLinkTagLabel(%q) = %q, want %q", c.in, got, c.want)
}
}
}
func TestLinkTagRegex_StopsBeforePunctuation(t *testing.T) {
s := `正文#碎片时间」。继续`
m := linkTagPlainTextRe.FindStringSubmatch(s)
if m == nil || len(m) < 2 {
t.Fatal("expected match")
}
if m[1] != "碎片时间" {
t.Fatalf("captured label = %q, want 碎片时间", m[1])
}
if strings.Contains(m[0], "。") {
t.Fatalf("match should not include 。: %q", m[0])
}
}
func TestLinkTagRegex_SpaceBreaksTag(t *testing.T) {
s := `#碎片时间」小 程序`
m := linkTagPlainTextRe.FindStringSubmatch(s)
if m == nil || m[1] != "碎片时间" {
t.Fatalf("got %v", m)
}
}