config+cmd/lncli: make cleanAndExpandPath return empty string on empty path
Co-Authored-By: Karl Ranna <karl@karlranna.com>
This commit is contained in:
parent
646e81262f
commit
6ddae25487
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user