mirror of
https://github.com/thegeeklab/drone-template-lib.git
synced 2024-11-16 09:50:39 +00:00
Added negative truncation to helper function
This allows you to grab a truncated portion of a string from the end.
This commit is contained in:
parent
8efa917a1f
commit
be0e4a22ab
@ -100,13 +100,18 @@ func isFailure(conditional bool, options *raymond.Options) string {
|
||||
}
|
||||
|
||||
func truncate(s string, len int) string {
|
||||
if utf8.RuneCountInString(s) <= len {
|
||||
if utf8.RuneCountInString(s) <= int(math.Abs(float64(len))) {
|
||||
return s
|
||||
}
|
||||
|
||||
runes := []rune(s)
|
||||
|
||||
if len < 0 {
|
||||
len = -len
|
||||
return string(runes[len:])
|
||||
} else {
|
||||
return string(runes[:len])
|
||||
}
|
||||
}
|
||||
|
||||
func urlencode(options *raymond.Options) string {
|
||||
|
Loading…
Reference in New Issue
Block a user