config/Path: simplify tilde expansion

This commit is contained in:
Max Kellermann 2025-03-11 09:16:18 +01:00
parent f4f5e94a36
commit e8a4317f31

@ -80,17 +80,12 @@ ParsePath(std::string_view path)
if (path.empty())
return GetConfiguredHome();
if (path.front() == '/') {
path.remove_prefix(1);
const auto [user, rest] = Split(path, '/');
const auto home = user.empty()
? GetConfiguredHome()
: GetHome(std::string{user}.c_str());
return GetConfiguredHome() /
AllocatedPath::FromUTF8Throw(path);
} else {
const auto [user, rest] = Split(path, '/');
return GetHome(std::string{user}.c_str())
/ AllocatedPath::FromUTF8Throw(rest);
}
return home / AllocatedPath::FromUTF8Throw(rest);
} else if (path.starts_with('$')) {
path.remove_prefix(1);