config/Path: simplify tilde expansion
This commit is contained in:
@ -80,17 +80,12 @@ ParsePath(std::string_view path)
|
|||||||
if (path.empty())
|
if (path.empty())
|
||||||
return GetConfiguredHome();
|
return GetConfiguredHome();
|
||||||
|
|
||||||
if (path.front() == '/') {
|
const auto [user, rest] = Split(path, '/');
|
||||||
path.remove_prefix(1);
|
const auto home = user.empty()
|
||||||
|
? GetConfiguredHome()
|
||||||
|
: GetHome(std::string{user}.c_str());
|
||||||
|
|
||||||
return GetConfiguredHome() /
|
return home / AllocatedPath::FromUTF8Throw(rest);
|
||||||
AllocatedPath::FromUTF8Throw(path);
|
|
||||||
} else {
|
|
||||||
const auto [user, rest] = Split(path, '/');
|
|
||||||
|
|
||||||
return GetHome(std::string{user}.c_str())
|
|
||||||
/ AllocatedPath::FromUTF8Throw(rest);
|
|
||||||
}
|
|
||||||
} else if (path.starts_with('$')) {
|
} else if (path.starts_with('$')) {
|
||||||
path.remove_prefix(1);
|
path.remove_prefix(1);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user