diff options
author | Matthias Loibl <mail@matthiasloibl.com> | 2016-11-07 21:27:14 +0100 |
---|---|---|
committer | Matthias Loibl <mail@matthiasloibl.com> | 2016-11-07 23:31:39 +0100 |
commit | 030ba2894f3e9f9442b4bbf83fec09bda1ca88c5 (patch) | |
tree | 4e186189b1062603887284d4cae20b6c166b8ebe /modules/base/tool.go | |
parent | f81711f40d46208917742b871c41fe74a4b214c1 (diff) | |
download | gitea-030ba2894f3e9f9442b4bbf83fec09bda1ca88c5.tar.gz gitea-030ba2894f3e9f9442b4bbf83fec09bda1ca88c5.zip |
Add tests for EllipsisString() and fix bug if param length < 3
Diffstat (limited to 'modules/base/tool.go')
-rw-r--r-- | modules/base/tool.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go index ff072f857f..9177cfe193 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -462,7 +462,10 @@ func Subtract(left interface{}, right interface{}) interface{} { // EllipsisString returns a truncated short string, // it appends '...' in the end of the length of string is too large. func EllipsisString(str string, length int) string { - if len(str) < length { + if length <= 3 { + return "..." + } + if len(str) <= length { return str } return str[:length-3] + "..." |