ci: fix lint and test failures

This commit is contained in:
shaw 2026-05-07 19:26:18 +08:00
parent 57fd7998d3
commit 8a835b22bb
2 changed files with 33 additions and 15 deletions

View File

@ -649,6 +649,15 @@ func TestAPIContracts(t *testing.T) {
"frontend_url": "", "frontend_url": "",
"totp_enabled": false, "totp_enabled": false,
"totp_encryption_key_configured": false, "totp_encryption_key_configured": false,
"login_agreement_enabled": false,
"login_agreement_mode": "modal",
"login_agreement_updated_at": "2026-03-31",
"login_agreement_documents": [
{"id": "terms", "title": "服务条款", "content_md": ""},
{"id": "usage-policy", "title": "使用政策", "content_md": ""},
{"id": "supported-regions", "title": "支持的国家和地区", "content_md": ""},
{"id": "service-specific-terms", "title": "服务特定条款", "content_md": ""}
],
"smtp_host": "smtp.example.com", "smtp_host": "smtp.example.com",
"smtp_port": 587, "smtp_port": 587,
"smtp_username": "user", "smtp_username": "user",
@ -883,6 +892,15 @@ func TestAPIContracts(t *testing.T) {
"invitation_code_enabled": false, "invitation_code_enabled": false,
"totp_enabled": false, "totp_enabled": false,
"totp_encryption_key_configured": false, "totp_encryption_key_configured": false,
"login_agreement_enabled": false,
"login_agreement_mode": "modal",
"login_agreement_updated_at": "2026-03-31",
"login_agreement_documents": [
{"id": "terms", "title": "服务条款", "content_md": ""},
{"id": "usage-policy", "title": "使用政策", "content_md": ""},
{"id": "supported-regions", "title": "支持的国家和地区", "content_md": ""},
{"id": "service-specific-terms", "title": "服务特定条款", "content_md": ""}
],
"smtp_host": "", "smtp_host": "",
"smtp_port": 587, "smtp_port": 587,
"smtp_username": "", "smtp_username": "",

View File

@ -249,16 +249,16 @@ func normalizeLoginAgreementDocumentID(raw string) string {
lastSeparator := false lastSeparator := false
for _, r := range raw { for _, r := range raw {
if (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') { if (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') {
b.WriteRune(r) _, _ = b.WriteRune(r)
lastSeparator = false lastSeparator = false
continue continue
} }
if r == '-' || r == '_' || r == ' ' || r == '.' || r == '/' { if r == '-' || r == '_' || r == ' ' || r == '.' || r == '/' {
if !lastSeparator && b.Len() > 0 { if !lastSeparator && b.Len() > 0 {
if r == '_' { if r == '_' {
b.WriteRune('_') _, _ = b.WriteRune('_')
} else { } else {
b.WriteRune('-') _, _ = b.WriteRune('-')
} }
lastSeparator = true lastSeparator = true
} }