Properly handle URL parse errors
Fixes
@@ -78,9 +78,11 @@ func extractHostname(in string) string {
urlStr = "http://" + urlStr
}
u, err := url.Parse(urlStr)
- if ch := fsutil.CleanFilename(u.Hostname()); err == nil && ch != "" {
+ if err == nil {
+ if ch := fsutil.CleanFilename(u.Hostname()); ch != "" {
return ch
}
+ }
return fsutil.CleanFilename(in)
}
