Skip to content

splitdrive under windows #19695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 4, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ elseif is_windows()
const path_ext_splitter = r"^((?:.*[/\\])?(?:\.|[^/\\\.])[^/\\]*?)(\.[^/\\\.]*|)$"

function splitdrive(path::String)
m = match(r"^(\w+:|\\\\\w+\\\w+|\\\\\?\\UNC\\\w+\\\w+|\\\\\?\\\w+:|)(.*)$", path)
m = match(r"^([^\\]+:|\\\\[^\\]+\\[^\\]+|\\\\\?\\UNC\\[^\\]+\\[^\\]+|\\\\\?\\[^\\]+:|)(.*)$", path)
String(m.captures[1]), String(m.captures[2])
end
else
Expand Down
9 changes: 9 additions & 0 deletions test/path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ for S in (String, GenericString)
@test joinpath(splitdir(S(homedir()))...) == homedir()
@test string(splitdrive(S(homedir()))...) == homedir()

if is_windows()
@test splitdrive("\\\\servername\\hello.world\\filename.ext") ==
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is inside a loop over S but you aren't using S like all the other tests here do (testing either String or GenericString as an approximation of unicode handling)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair point. moved tests outside the loop over S

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would have also worked to change the test cases to S("...")

("\\\\servername\\hello.world","\\filename.ext")
@test splitdrive("\\\\servername.com\\hello.world\\filename.ext") ==
("\\\\servername.com\\hello.world","\\filename.ext")
@test splitdrive("C:\\foo\\bar") ==
("C:","\\foo\\bar")
end

@test splitext(S("")) == ("", "")
@test splitext(S(".")) == (".", "")
@test_broken splitext(S("..")) == ("..", "")
Expand Down