Skip to content

Commit 3690042

Browse files
authored
Fix DialogJump UriFormatException when navigating to root directories (#4052)
1 parent 3d9ef2c commit 3690042

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

Flow.Launcher.Infrastructure/DialogJump/DialogJump.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -828,9 +828,25 @@ private static bool CheckPath(string path, out bool file)
828828
return true;
829829
}
830830
// file: URI paths
831-
var localPath = path.StartsWith("file:", StringComparison.OrdinalIgnoreCase)
832-
? new Uri(path).LocalPath
833-
: path;
831+
string localPath;
832+
if (path.StartsWith("file:", StringComparison.OrdinalIgnoreCase))
833+
{
834+
// Try to create a URI from the path
835+
if (Uri.TryCreate(path, UriKind.Absolute, out var uri))
836+
{
837+
localPath = uri.LocalPath;
838+
}
839+
else
840+
{
841+
// If URI creation fails, treat it as a regular path
842+
// by removing the "file:" prefix
843+
localPath = path.Substring(5);
844+
}
845+
}
846+
else
847+
{
848+
localPath = path;
849+
}
834850
// Is folder?
835851
var isFolder = Directory.Exists(localPath);
836852
// Is file?

0 commit comments

Comments
 (0)