From 97fc9c02a50bb264d1523434524f593e3d155369 Mon Sep 17 00:00:00 2001 From: Ali Rizvi-Santiago Date: Thu, 18 Jan 2018 23:58:24 -0600 Subject: [PATCH] Grr...missed the case that actually mattered on linux. --- common/config.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/common/config.go b/common/config.go index fa9dba55b..6850005d7 100644 --- a/common/config.go +++ b/common/config.go @@ -72,7 +72,12 @@ func SupportedURL(u *url.URL) bool { // and so DownloadableURL will return "file://local/file.iso" // No other transformations are done to the path. func DownloadableURL(original string) (string, error) { - var result string + var absPrefix, result string + + absPrefix = "" + if runtime.GOOS == "windows" { + absPrefix = "/" + } // Check that the user specified a UNC path, and promote it to an smb:// uri. if strings.HasPrefix(original, "\\\\") && len(original) > 2 && original[2] != '?' { @@ -118,15 +123,12 @@ func DownloadableURL(original string) (string, error) { } result = filepath.Clean(result) - return fmt.Sprintf("file:///%s", filepath.ToSlash(result)), nil + return fmt.Sprintf("file://%s%s", absPrefix, filepath.ToSlash(result)), nil } // Otherwise, check if it was originally an absolute path, and fix it if so. if strings.HasPrefix(original, "/") { - if runtime.GOOS == "windows" { - return fmt.Sprintf("file:///%s", result), nil - } - return fmt.Sprintf("file://%s", result), nil + return fmt.Sprintf("file://%s%s", absPrefix, result), nil } // Anything left should be a non-existent relative path. So fix it up here.