aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/helpers
diff options
context:
space:
mode:
authormemchr <[email protected]>2023-09-14 11:07:31 +0000
committerGitHub <[email protected]>2023-09-14 12:07:31 +0100
commitdb2b72adee6e76cf25edac0eb9e69387c8dd5ee6 (patch)
tree3d7b8f246e0cfeea05e6ee3f0bd6e7724f9d739a /src/helpers
parent0dc8289b0292d3c3c35a06fdecbe41cd57a1a918 (diff)
downloadHyprland-db2b72adee6e76cf25edac0eb9e69387c8dd5ee6.tar.gz
Hyprland-db2b72adee6e76cf25edac0eb9e69387c8dd5ee6.zip
config: fix relative path resolution (#3308)
Diffstat (limited to 'src/helpers')
-rw-r--r--src/helpers/MiscFunctions.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp
index 9000eff2..218c2332 100644
--- a/src/helpers/MiscFunctions.cpp
+++ b/src/helpers/MiscFunctions.cpp
@@ -126,20 +126,22 @@ static const float transforms[][9] = {
std::string absolutePath(const std::string& rawpath, const std::string& currentPath) {
auto value = rawpath;
- if (value[0] == '.') {
- auto currentDir = currentPath.substr(0, currentPath.find_last_of('/'));
-
- if (value[1] == '.') {
- auto parentDir = currentDir.substr(0, currentDir.find_last_of('/'));
- value.replace(0, 2 + currentPath.empty(), parentDir);
- } else {
- value.replace(0, 1 + currentPath.empty(), currentDir);
- }
- }
-
if (value[0] == '~') {
static const char* const ENVHOME = getenv("HOME");
value.replace(0, 1, std::string(ENVHOME));
+ } else if (value[0] != '/') {
+ auto currentDir = currentPath.substr(0, currentPath.find_last_of('/'));
+
+ if (value[0] == '.') {
+ if (value[1] == '.' && value[2] == '/') {
+ auto parentDir = currentDir.substr(0, currentDir.find_last_of('/'));
+ value.replace(0, 2 + currentPath.empty(), parentDir);
+ } else if (value[1] == '/')
+ value.replace(0, 1 + currentPath.empty(), currentDir);
+ else
+ value = currentDir + '/' + value;
+ } else
+ value = currentDir + '/' + value;
}
return value;