diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-09-03 09:43:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-03 01:43:29 +0000 |
commit | c802c46a9beeaed44d41f50de31a4db146cdd8f7 (patch) | |
tree | 9492798f81da6949f23e4d1f79ed8528f226dac3 /modules/templates/util_string.go | |
parent | 9a3de436f452144933888fb1e4f336efeb93293a (diff) | |
download | gitea-c802c46a9beeaed44d41f50de31a4db146cdd8f7.tar.gz gitea-c802c46a9beeaed44d41f50de31a4db146cdd8f7.zip |
Refactor `og:description` to limit the max length (#26876)
1. The `og:description` should be "a one to two sentence description of
your object"
* It shouldn't output all the user inputted content -- it would be
pretty huge.
* Maybe it only needs at most 300 bytes.
2. Do not render commit message as HTML
Diffstat (limited to 'modules/templates/util_string.go')
-rw-r--r-- | modules/templates/util_string.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/templates/util_string.go b/modules/templates/util_string.go index 459380aee5..18a0d5cacc 100644 --- a/modules/templates/util_string.go +++ b/modules/templates/util_string.go @@ -33,6 +33,11 @@ func (su *StringUtils) Join(a []string, sep string) string { return strings.Join(a, sep) } +func (su *StringUtils) Cut(s, sep string) []any { + before, after, found := strings.Cut(s, sep) + return []any{before, after, found} +} + func (su *StringUtils) EllipsisString(s string, max int) string { return base.EllipsisString(s, max) } |