1
0
Fork 0
forked from forgejo/forgejo

templates: HasPrefix support for template.HTML

Refactor locale&string&template related code has .Title be
template.HTML and "Improve HTML title on repositories" needs to check
the prefix with StringUtils.HasPrefix
This commit is contained in:
Earl Warren 2024-02-15 15:56:17 +01:00
parent 4af0944b26
commit c021a5b919
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
2 changed files with 29 additions and 2 deletions

View file

@ -0,0 +1,20 @@
// Copyright Earl Warren <contact@earl-warren.org>
// SPDX-License-Identifier: MIT
package templates
import (
"html/template"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_StringUtils_HasPrefix(t *testing.T) {
su := &StringUtils{}
assert.True(t, su.HasPrefix("ABC", "A"))
assert.False(t, su.HasPrefix("ABC", "B"))
assert.True(t, su.HasPrefix(template.HTML("ABC"), "A"))
assert.False(t, su.HasPrefix(template.HTML("ABC"), "B"))
assert.False(t, su.HasPrefix(123, "B"))
}