Browse Source

Expand ~/ on Windows as well

Jakob Borg 11 years ago
parent
commit
8661afcb4f
2 changed files with 6 additions and 2 deletions
  1. 1 1
      cmd/syncthing/gui.go
  2. 5 1
      cmd/syncthing/main.go

+ 1 - 1
cmd/syncthing/gui.go

@@ -244,7 +244,7 @@ func restGetSystem(w http.ResponseWriter) {
 	res["goroutines"] = runtime.NumGoroutine()
 	res["alloc"] = m.Alloc
 	res["sys"] = m.Sys
-	res["tilde"] = expandTilde("~/")
+	res["tilde"] = expandTilde("~")
 	if cfg.Options.GlobalAnnEnabled && discoverer != nil {
 		res["extAnnounceOK"] = discoverer.ExtAnnounceOK()
 	}

+ 5 - 1
cmd/syncthing/main.go

@@ -679,7 +679,11 @@ func getDefaultConfDir() string {
 }
 
 func expandTilde(p string) string {
-	if runtime.GOOS == "windows" || !strings.HasPrefix(p, "~/") {
+	if p == "~" {
+		return getHomeDir()
+	}
+
+	if !strings.HasPrefix(p, fmt.Sprintf("~%c", os.PathSeparator)) {
 		return p
 	}