Merge pull request #6547 from Faker-09/volume_name_len_fix

Fix os._volume_name_len to handle paths of purely path separators
This commit is contained in:
Jeroen van Rijn
2026-04-10 17:14:57 +02:00
committed by GitHub

View File

@@ -377,17 +377,25 @@ _volume_name_len :: proc(path: string) -> (length: int) {
// UNC path, minimum version of the volume is `\\h\s` for host, share.
// Can also contain an IP address in the host position.
// (path might be purely path separators)
slash_count := 0
found_host: bool
for i in prefix..<len(path) {
// Host needs to be at least 1 character
if _is_path_separator(path[i]) && i > 0 {
if _is_path_separator(path[i]) {
slash_count += 1
if slash_count == 2 {
if slash_count == 2 && found_host {
return i
}
} else {
found_host = true
// Found a host but no trailing slash `\\h\s`
if slash_count == 1 && i == len(path)-1 {
return len(path)
}
}
}
return len(path)
return 0
}