mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: fix os.file_ext('/tmp/.gitignore')
previously returning '.gitignore' => it now returns '' (#16771)
This commit is contained in:
parent
64ed007f94
commit
68883fc4d9
@ -209,10 +209,11 @@ pub fn is_dir_empty(path string) bool {
|
||||
// assert os.file_ext('.ignore_me') == ''
|
||||
// assert os.file_ext('.') == ''
|
||||
// ```
|
||||
pub fn file_ext(path string) string {
|
||||
if path.len < 3 {
|
||||
pub fn file_ext(opath string) string {
|
||||
if opath.len < 3 {
|
||||
return empty_str
|
||||
}
|
||||
path := file_name(opath)
|
||||
pos := path.last_index(dot_str) or { return empty_str }
|
||||
if pos + 1 >= path.len || pos == 0 {
|
||||
return empty_str
|
||||
|
@ -599,6 +599,10 @@ fn test_file_ext() {
|
||||
assert os.file_ext('file...') == ''
|
||||
assert os.file_ext('.file.') == ''
|
||||
assert os.file_ext('..file..') == ''
|
||||
assert os.file_ext('./.git') == ''
|
||||
assert os.file_ext('./.git/') == ''
|
||||
assert os.file_ext('\\.git') == ''
|
||||
assert os.file_ext('\\.git\\') == ''
|
||||
}
|
||||
|
||||
fn test_join() {
|
||||
|
Loading…
Reference in New Issue
Block a user