mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 10:50:54 +00:00
beego: template fund when the start> len(bt)
This commit is contained in:
parent
a3f40234ca
commit
ea6982fcea
@ -27,6 +27,9 @@ func Substr(s string, start, length int) string {
|
||||
if start < 0 {
|
||||
start = 0
|
||||
}
|
||||
if start > len(bt) {
|
||||
start = start % len(bt)
|
||||
}
|
||||
var end int
|
||||
if (start + length) > (len(bt) - 1) {
|
||||
end = len(bt)
|
||||
|
@ -25,6 +25,9 @@ func TestSubstr(t *testing.T) {
|
||||
if Substr(s, 0, 100) != "012345" {
|
||||
t.Error("should be equal")
|
||||
}
|
||||
if Substr(s, 12, 100) != "012345" {
|
||||
t.Error("should be equal")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHtml2str(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user