opscode/chef — pull request #1343 by Tensibai (2014-03-27 14:27:57+00:00)
Title: CHEF-4472 remote_file resource fails on windows host for any defined source

CHEF-4472 remote_file resource fails on windows host for any defined source

URI.parse("file:///c:/file.txt").path return /c:/files.txt which is not correct for File class methods, the leading slash has to be removed.

To restrict potential leading slash removal under *nix I extented the regex to letter and : so the only caveat under *nix is path starting by /:/ which sounds unlikely to appear and anyway could be worked around with a temp link if needed.

As I'm not sure I had explained it clearly I commented my tests under irb:
```ruby
#Let's try to access a file
irb(main):005:0> URI.parse("file://z:/all.js").path
=> "/all.js"
#Ok, it needs an extra / at start

irb(main):006:0> URI.parse("file:///z:/all.js").path
=> "/z:/all.js"
#Great I've my file (seems) does File understand this path ?

irb(main):008:0> File.file?(URI.parse("file:///z:/all.js").path)
=> false
#Hum ok, maybe it would be able to figure it out anyway...

irb(main):007:0> File.file?(URI.parse("file://z:/all.js").path)
=> false
#Still not, I need the drive letter without the extra slash at start, let try gsub

irb(main):009:0> URI.parse("file:///z:/all.js").path.gsub(/^\/([a-zA-Z]:)/,'\1')
=> "z:/all.js"
irb(main):010:0> File.file?(URI.parse("file:///z:/all.js").path.gsub(/^\/([a-zA-Z]:)/,'\1'))
=> true

#It works ;)
```