Skip to content

Commit ef39b9d

Browse files
authored
Merge pull request #144 from JohnTheGr8/fix_env_var_paths
plugin/explorer: ensure environment variable paths are absolute
2 parents 400caa6 + 17f94a1 commit ef39b9d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Search/EnvironmentVariables.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,20 @@ internal static Dictionary<string, string> LoadEnvironmentStringPaths()
2222

2323
foreach (DictionaryEntry special in Environment.GetEnvironmentVariables())
2424
{
25-
if (Directory.Exists(special.Value.ToString()))
25+
var path = special.Value.ToString();
26+
if (Directory.Exists(path))
2627
{
28+
// we add a trailing slash to the path to make sure drive paths become valid absolute paths.
29+
// for example, if %systemdrive% is C: we turn it to C:\
30+
path = path.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar;
31+
32+
// if we don't have an absolute path, we use Path.GetFullPath to get one.
33+
// for example, if %homepath% is \Users\John we turn it to C:\Users\John
34+
path = Path.IsPathFullyQualified(path) ? path : Path.GetFullPath(path);
35+
2736
// Variables are returned with a mixture of all upper/lower case.
2837
// Call ToLower() to make the results look consistent
29-
envStringPaths.Add(special.Key.ToString().ToLower(), special.Value.ToString());
38+
envStringPaths.Add(special.Key.ToString().ToLower(), path);
3039
}
3140
}
3241

Plugins/Flow.Launcher.Plugin.Explorer/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"Name": "Explorer",
88
"Description": "Search and manage files and folders. Explorer utilises Windows Index Search",
99
"Author": "Jeremy Wu",
10-
"Version": "1.2.1",
10+
"Version": "1.2.2",
1111
"Language": "csharp",
1212
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1313
"ExecuteFileName": "Flow.Launcher.Plugin.Explorer.dll",

0 commit comments

Comments
 (0)