fix:优化SubstringFunction负数处理逻辑

This commit is contained in:
rulego-team
2025-08-06 10:55:28 +08:00
parent f3fe997ce8
commit 691ca41c87
+7
View File
@@ -295,6 +295,9 @@ func (f *SubstringFunction) Execute(ctx *FunctionContext, args []interface{}) (i
}
strLen := int64(len(str))
if start < 0 {
start = strLen + start
}
if start < 0 || start >= strLen {
return "", nil
}
@@ -308,6 +311,10 @@ func (f *SubstringFunction) Execute(ctx *FunctionContext, args []interface{}) (i
return nil, err
}
if length < 0 {
return "", nil
}
end := start + length
if end > strLen {
end = strLen