Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Oct 15, 2025

Problem

The DialogJump function fails when attempting to navigate to root directories (e.g., C:\), throwing a UriFormatException with the message:

Invalid URI: A Dos path must be rooted, for example, 'c:\\'.

This occurs when paths are passed with a file: prefix but without proper URI formatting, such as file:C: (missing the trailing slash).

Root Cause

The CheckPath method in DialogJump.cs was using the Uri constructor directly:

var localPath = path.StartsWith("file:", StringComparison.OrdinalIgnoreCase)
    ? new Uri(path).LocalPath
    : path;

The Uri constructor throws UriFormatException when given malformed file URIs like file:C: (without trailing slash), causing DialogJump to fail for root directories.

Solution

Replaced the direct Uri constructor call with Uri.TryCreate() to gracefully handle malformed URIs:

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;
}

This approach:

  • ✅ Handles properly formatted file URIs using the standard Uri.LocalPath property
  • ✅ Gracefully degrades for malformed URIs by stripping the file: prefix
  • ✅ Allows the subsequent Directory.Exists() and File.Exists() checks to determine if the path is valid
  • ✅ Maintains full backward compatibility with existing functionality

Testing

Verified the fix handles various path formats correctly:

  • Root directories: file:C:, file:D: no longer throw exceptions
  • Properly formatted URIs: file:///C:/, file://C:/ continue to work
  • Regular paths: C:\, D:\ work as expected
  • Shell paths: shell:MyComputerFolder continue to work

Fixes #[issue_number]

Original prompt

This section details on the original issue you should resolve

<issue_title>BUG: Dialog Jump does not work in the root directory</issue_title>
<issue_description>### Checks

  • I have checked that this issue has not already been reported.

  • I am using the latest version of Flow Launcher.

  • I am using the prerelease version of Flow Launcher.

Problem Description

The dialog jump function does not work in the root directory, but functions normally in other directories.

To Reproduce

  1. ...
  2. ...
  3. ...

Screenshots

No response

Flow Launcher Version

2.0.2

Windows Build Number

10.0.26100.6725

Error Log

21:40:22.4694+08:00 - ERROR - DialogJump.CheckPath - Failed to check path
EXCEPTION OCCURS: System.UriFormatException: Invalid URI: A Dos path must be rooted, for example, 'c:\'.
at void Uri.CreateThis(string uri, bool dontEscape, UriKind uriKind, in UriCreationOptions creationOptions)
at new Uri(string uriString)
at bool Flow.Launcher.Infrastructure.DialogJump.DialogJump.CheckPath(string path, out bool file) in C:/projects/flow-launcher/Flow.Launcher.Infrastructure/DialogJump/DialogJump.cs:line 835

</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #4048


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@prlabeler prlabeler bot added the bug Something isn't working label Oct 15, 2025
Replace new Uri() with Uri.TryCreate() to handle malformed file: URIs gracefully. When file: prefix is present but URI parsing fails (e.g., "file:C:" without trailing slash), the code now strips the prefix and uses the path directly instead of throwing an exception.

Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Fix dialog jump functionality in root directory Fix DialogJump UriFormatException when navigating to root directories Oct 15, 2025
@Copilot Copilot AI requested a review from Jack251970 October 15, 2025 04:49
Copilot finished work on behalf of Jack251970 October 15, 2025 04:49
@Jack251970 Jack251970 removed their request for review October 15, 2025 04:53
@Jack251970 Jack251970 closed this Oct 15, 2025
@jjw24 jjw24 deleted the copilot/fix-dialog-jump-root-directory branch October 15, 2025 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Dialog Jump does not work in the root directory

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.