builder/common: Don't prepend slash to URL path if path is empty
This commit is contained in:
parent
ac8548d998
commit
85ec53e76c
@ -2,11 +2,11 @@ package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
@ -97,7 +97,7 @@ func DownloadableURL(original string) (string, error) {
|
||||
// we distribute with a version of Go that fixes that bug.
|
||||
//
|
||||
// See: https://code.google.com/p/go/issues/detail?id=5927
|
||||
if url.Path[0] != '/' {
|
||||
if url.Path != "" && url.Path[0] != '/' {
|
||||
url.Path = "/" + url.Path
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,16 @@ func TestDownloadableURL(t *testing.T) {
|
||||
if u != "http://packer.io/path" {
|
||||
t.Fatalf("bad: %s", u)
|
||||
}
|
||||
|
||||
// No path
|
||||
u, err = DownloadableURL("HTTP://packer.io")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if u != "http://packer.io" {
|
||||
t.Fatalf("bad: %s", u)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDownloadableURL_FilePaths(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user