mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
io: cleanup prefix_and_suffix/1 util function (#21562)
This commit is contained in:
parent
14018f1c45
commit
a7cf1ad7d5
1 changed files with 2 additions and 11 deletions
|
@ -77,18 +77,9 @@ fn random_number() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prefix_and_suffix(pattern string) !(string, string) {
|
fn prefix_and_suffix(pattern string) !(string, string) {
|
||||||
mut pat := pattern
|
if pattern.contains(os.path_separator) {
|
||||||
if pat.contains(os.path_separator) {
|
|
||||||
return error('pattern cannot contain path separators (${os.path_separator}).')
|
return error('pattern cannot contain path separators (${os.path_separator}).')
|
||||||
}
|
}
|
||||||
pos := pat.index_u8_last(`*`)
|
prefix, suffix := pattern.rsplit_once('*') or { pattern, '' }
|
||||||
mut prefix := ''
|
|
||||||
mut suffix := ''
|
|
||||||
if pos != -1 {
|
|
||||||
prefix = pat.substr(0, pos)
|
|
||||||
suffix = pat.substr(pos + 1, pat.len)
|
|
||||||
} else {
|
|
||||||
prefix = pat
|
|
||||||
}
|
|
||||||
return prefix, suffix
|
return prefix, suffix
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue