common: detect drive letter with windows file URLs [GH-284]
This commit is contained in:
parent
359f639e05
commit
9e01b5a478
|
@ -27,6 +27,8 @@ IMPROVEMENTS:
|
||||||
|
|
||||||
BUG FIXES:
|
BUG FIXES:
|
||||||
|
|
||||||
|
* windows: file URLs are easier to get right as Packer
|
||||||
|
has better parsing and error handling for Windows file paths. [GH-284]
|
||||||
* builder/amazon-instance: send IAM instance profile data. [GH-294]
|
* builder/amazon-instance: send IAM instance profile data. [GH-294]
|
||||||
* builder/virtualbox: dowload progress won't be shown until download
|
* builder/virtualbox: dowload progress won't be shown until download
|
||||||
actually starts. [GH-288]
|
actually starts. [GH-288]
|
||||||
|
|
|
@ -64,6 +64,15 @@ func DecodeConfig(target interface{}, raws ...interface{}) (*mapstructure.Metada
|
||||||
// a completely valid URL. For example, the original URL might be "local/file.iso"
|
// a completely valid URL. For example, the original URL might be "local/file.iso"
|
||||||
// which isn't a valid URL. DownloadableURL will return "file:///local/file.iso"
|
// which isn't a valid URL. DownloadableURL will return "file:///local/file.iso"
|
||||||
func DownloadableURL(original string) (string, error) {
|
func DownloadableURL(original string) (string, error) {
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
// If the distance to the first ":" is just one character, assume
|
||||||
|
// we're dealing with a drive letter and thus a file path.
|
||||||
|
idx := strings.Index(original, ":")
|
||||||
|
if idx == 1 {
|
||||||
|
original = "file:///" + original
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
url, err := url.Parse(original)
|
url, err := url.Parse(original)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
Loading…
Reference in New Issue