common: replace windows file URL backslash with forward slash

/cc @jasonberanek - Just adding this as well because I see this being
common as well.
This commit is contained in:
Mitchell Hashimoto 2013-08-03 13:38:27 -07:00
parent c2654ddb59
commit 2b41f05848
1 changed files with 5 additions and 0 deletions

View File

@ -78,6 +78,11 @@ func DownloadableURL(original string) (string, error) {
// since net/url turns "C:/" into "/C:/"
if runtime.GOOS == "windows" && url.Path[0] == '/' {
url.Path = url.Path[1:len(url.Path)]
// Also replace all backslashes with forwardslashes since Windows
// users are likely to do this but the URL should actually only
// contain forward slashes.
url.Path = strings.Replace(url.Path, `\`, `/`, -1)
}
if _, err := os.Stat(url.Path); err != nil {