Fix DialogJump UriFormatException when navigating to root directories (#4052)

This commit is contained in:
Jack Ye 2025-10-15 17:12:51 +08:00 committed by GitHub
parent 3d9ef2c63f
commit 3690042d2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -828,9 +828,25 @@ namespace Flow.Launcher.Infrastructure.DialogJump
return true;
}
// file: URI paths
var localPath = path.StartsWith("file:", StringComparison.OrdinalIgnoreCase)
? new Uri(path).LocalPath
: path;
string localPath;
if (path.StartsWith("file:", StringComparison.OrdinalIgnoreCase))
{
// Try to create a URI from the path
if (Uri.TryCreate(path, UriKind.Absolute, out var uri))
{
localPath = uri.LocalPath;
}
else
{
// If URI creation fails, treat it as a regular path
// by removing the "file:" prefix
localPath = path.Substring(5);
}
}
else
{
localPath = path;
}
// Is folder?
var isFolder = Directory.Exists(localPath);
// Is file?