`box.url` can use `file://` URI
This commit is contained in:
parent
ed1bc58735
commit
50c04ac927
|
@ -1,4 +1,5 @@
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
require 'uri'
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module Downloaders
|
module Downloaders
|
||||||
|
@ -6,7 +7,8 @@ module Vagrant
|
||||||
# simply does a file copy.
|
# simply does a file copy.
|
||||||
class File < Base
|
class File < Base
|
||||||
def self.match?(uri)
|
def self.match?(uri)
|
||||||
::File.file?(::File.expand_path(uri))
|
extracted = URI.extract(uri, "file")
|
||||||
|
(extracted && extracted.include?(uri)) || ::File.file?(::File.expand_path(uri))
|
||||||
end
|
end
|
||||||
|
|
||||||
def download!(source_url, destination_file)
|
def download!(source_url, destination_file)
|
||||||
|
|
|
@ -10,7 +10,7 @@ module Vagrant
|
||||||
class HTTP < Base
|
class HTTP < Base
|
||||||
def self.match?(uri)
|
def self.match?(uri)
|
||||||
# URI.parse barfs on '<drive letter>:\\files \on\ windows'
|
# URI.parse barfs on '<drive letter>:\\files \on\ windows'
|
||||||
extracted = URI.extract(uri).first
|
extracted = URI.extract(uri, ['http', 'https']).first
|
||||||
extracted && extracted.include?(uri)
|
extracted && extracted.include?(uri)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,10 @@ describe Vagrant::Downloaders::File do
|
||||||
ENV["HOME"] = old_home
|
ENV["HOME"] = old_home
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should match file:// URIs" do
|
||||||
|
described_class.match?("file://#{__FILE__}").should be
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "downloading" do
|
describe "downloading" do
|
||||||
|
|
|
@ -11,6 +11,10 @@ describe Vagrant::Downloaders::HTTP do
|
||||||
described_class.match?("http://foo:bar@google.com/foo.box").should be
|
described_class.match?("http://foo:bar@google.com/foo.box").should be
|
||||||
described_class.match?("http://google.com:8500/foo.box").should be
|
described_class.match?("http://google.com:8500/foo.box").should be
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should not match file:// URIs" do
|
||||||
|
described_class.match?("file://#{__FILE__}").should_not be
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "downloading" do
|
describe "downloading" do
|
||||||
|
|
Loading…
Reference in New Issue