mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
string: fix trim_prefix and trim_suffix methods (#5572)
This commit is contained in:
@ -921,14 +921,14 @@ pub fn (s string) trim_right(cutset string) string {
|
||||
|
||||
pub fn (s string) trim_prefix(str string) string {
|
||||
if s.starts_with(str) {
|
||||
return s.replace(str, "")
|
||||
return s[str.len..]
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
pub fn (s string) trim_suffix(str string) string {
|
||||
if s.ends_with(str) {
|
||||
return s.replace(str, "")
|
||||
return s[..s.len-str.len]
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
Reference in New Issue
Block a user