mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-24 21:56:05 +02:00
tpl: Fix substr when length parameter is zero
When length parameter is zero, always return an empty string. Updates #7993
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
64789fb5dc
commit
5862fd2a60
@@ -327,9 +327,12 @@ func (ns *Namespace) Substr(a interface{}, nums ...interface{}) (string, error)
|
||||
|
||||
end := rlen
|
||||
|
||||
if length < 0 {
|
||||
switch {
|
||||
case length == 0:
|
||||
return "", nil
|
||||
case length < 0:
|
||||
end += length
|
||||
} else if length > 0 {
|
||||
case length > 0:
|
||||
end = start + length
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user