Grr...missed the case that actually mattered on linux.
This commit is contained in:
parent
f9572cb244
commit
97fc9c02a5
|
@ -72,7 +72,12 @@ func SupportedURL(u *url.URL) bool {
|
||||||
// and so DownloadableURL will return "file://local/file.iso"
|
// and so DownloadableURL will return "file://local/file.iso"
|
||||||
// No other transformations are done to the path.
|
// No other transformations are done to the path.
|
||||||
func DownloadableURL(original string) (string, error) {
|
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.
|
// Check that the user specified a UNC path, and promote it to an smb:// uri.
|
||||||
if strings.HasPrefix(original, "\\\\") && len(original) > 2 && original[2] != '?' {
|
if strings.HasPrefix(original, "\\\\") && len(original) > 2 && original[2] != '?' {
|
||||||
|
@ -118,15 +123,12 @@ func DownloadableURL(original string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
result = filepath.Clean(result)
|
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.
|
// Otherwise, check if it was originally an absolute path, and fix it if so.
|
||||||
if strings.HasPrefix(original, "/") {
|
if strings.HasPrefix(original, "/") {
|
||||||
if runtime.GOOS == "windows" {
|
return fmt.Sprintf("file://%s%s", absPrefix, result), nil
|
||||||
return fmt.Sprintf("file:///%s", result), nil
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("file://%s", result), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Anything left should be a non-existent relative path. So fix it up here.
|
// Anything left should be a non-existent relative path. So fix it up here.
|
||||||
|
|
Loading…
Reference in New Issue