Skip to content
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

splitdrive under windows #19695

Merged
merged 6 commits into from
Jan 4, 2017
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions test/path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ 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") == ("\\\\servername\\hello.world","\\filename.ext")
@test splitdrive("\\\\servername.com\\hello.world\\filename.ext") == ("\\\\servername.com\\hello.world","\\filename.ext")
Copy link
Member

Choose a reason for hiding this comment

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

probably good to also have a C:\foo\bar test

Copy link
Contributor

Choose a reason for hiding this comment

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

should also wrap long lines, putting the rhs of the == on the next line would work well here

end

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