2023-04-22 23:46:22 +05:30
|
|
|
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
package templates
|
|
|
|
|
2023-04-29 17:32:29 +05:30
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/base"
|
|
|
|
)
|
2023-04-22 23:46:22 +05:30
|
|
|
|
|
|
|
type StringUtils struct{}
|
|
|
|
|
2023-04-29 17:32:29 +05:30
|
|
|
var stringUtils = StringUtils{}
|
|
|
|
|
2023-04-22 23:46:22 +05:30
|
|
|
func NewStringUtils() *StringUtils {
|
2023-04-29 17:32:29 +05:30
|
|
|
return &stringUtils
|
2023-04-22 23:46:22 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
func (su *StringUtils) HasPrefix(s, prefix string) bool {
|
|
|
|
return strings.HasPrefix(s, prefix)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (su *StringUtils) Contains(s, substr string) bool {
|
|
|
|
return strings.Contains(s, substr)
|
|
|
|
}
|
2023-04-29 02:53:19 +05:30
|
|
|
|
|
|
|
func (su *StringUtils) Split(s, sep string) []string {
|
|
|
|
return strings.Split(s, sep)
|
|
|
|
}
|
2023-04-29 17:32:29 +05:30
|
|
|
|
|
|
|
func (su *StringUtils) Join(a []string, sep string) string {
|
|
|
|
return strings.Join(a, sep)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (su *StringUtils) EllipsisString(s string, max int) string {
|
|
|
|
return base.EllipsisString(s, max)
|
|
|
|
}
|