config+cmd/lncli: make cleanAndExpandPath return empty string on empty path

Co-Authored-By: Karl Ranna <karl@karlranna.com>
This commit is contained in:
Wilmer PaulinoandKarl Ranna authored and Olaoluwa Osuntokun committed 2018-08-23 18:05:00 -07:00
1 parent 646e81262f
commit 6ddae25487
2 files changed
+8 -2

No files matched your search

+4 -1
View File
@@ -252,10 +252,13 @@ func main() {
// passed path, cleans the result, and returns it. // passed path, cleans the result, and returns it.
// This function is taken from https://github.com/btcsuite/btcd // This function is taken from https://github.com/btcsuite/btcd
func cleanAndExpandPath(path string) string { func cleanAndExpandPath(path string) string {
if path == "" {
return ""
}
// Expand initial ~ to OS specific home directory. // Expand initial ~ to OS specific home directory.
if strings.HasPrefix(path, "~") { if strings.HasPrefix(path, "~") {
var homeDir string var homeDir string
user, err := user.Current() user, err := user.Current()
if err == nil { if err == nil {
homeDir = user.HomeDir homeDir = user.HomeDir
+4 -1
View File
@@ -934,10 +934,13 @@ func loadConfig() (*config, error) {
// passed path, cleans the result, and returns it. // passed path, cleans the result, and returns it.
// This function is taken from https://github.com/btcsuite/btcd // This function is taken from https://github.com/btcsuite/btcd
func cleanAndExpandPath(path string) string { func cleanAndExpandPath(path string) string {
if path == "" {
return ""
}
// Expand initial ~ to OS specific home directory. // Expand initial ~ to OS specific home directory.
if strings.HasPrefix(path, "~") { if strings.HasPrefix(path, "~") {
var homeDir string var homeDir string
user, err := user.Current() user, err := user.Current()
if err == nil { if err == nil {
homeDir = user.HomeDir homeDir = user.HomeDir