Skip to content

Commit 7648ad6

Browse files
augustinyiptongtkelman
authored andcommitted
splitdrive under windows (#19695)
* splitdrive under windows * splitdrive under windows tests * more test * move tests outside loop over S * changed test cases to S("...")
1 parent c5c417c commit 7648ad6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

base/path.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ elseif is_windows()
3434
const path_ext_splitter = r"^((?:.*[/\\])?(?:\.|[^/\\\.])[^/\\]*?)(\.[^/\\\.]*|)$"
3535

3636
function splitdrive(path::String)
37-
m = match(r"^(\w+:|\\\\\w+\\\w+|\\\\\?\\UNC\\\w+\\\w+|\\\\\?\\\w+:|)(.*)$", path)
37+
m = match(r"^([^\\]+:|\\\\[^\\]+\\[^\\]+|\\\\\?\\UNC\\[^\\]+\\[^\\]+|\\\\\?\\[^\\]+:|)(.*)$", path)
3838
String(m.captures[1]), String(m.captures[2])
3939
end
4040
else

test/path.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ for S in (String, GenericString)
6868
@test joinpath(splitdir(S(homedir()))...) == homedir()
6969
@test string(splitdrive(S(homedir()))...) == homedir()
7070

71+
if is_windows()
72+
@test splitdrive(S("\\\\servername\\hello.world\\filename.ext")) ==
73+
("\\\\servername\\hello.world","\\filename.ext")
74+
@test splitdrive(S("\\\\servername.com\\hello.world\\filename.ext")) ==
75+
("\\\\servername.com\\hello.world","\\filename.ext")
76+
@test splitdrive(S("C:\\foo\\bar")) ==
77+
("C:","\\foo\\bar")
78+
end
79+
7180
@test splitext(S("")) == ("", "")
7281
@test splitext(S(".")) == (".", "")
7382
@test_broken splitext(S("..")) == ("..", "")

0 commit comments

Comments
 (0)