Skip to content

Commit 0b48a81

Browse files
committed
Fix UriFormatException
1 parent ba9bcbd commit 0b48a81

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

Files/Helpers/PathNormalization.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using NLog;
2+
using System;
23
using System.IO;
34

45
namespace Files.Helpers
@@ -22,9 +23,17 @@ public static string NormalizePath(string path)
2223
path += Path.DirectorySeparatorChar;
2324
}
2425

25-
return Path.GetFullPath(new Uri(path).LocalPath)
26-
.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)
27-
.ToUpperInvariant();
26+
try
27+
{
28+
return Path.GetFullPath(new Uri(path).LocalPath)
29+
.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)
30+
.ToUpperInvariant();
31+
}
32+
catch (UriFormatException ex)
33+
{
34+
LogManager.GetCurrentClassLogger().Error(ex, path);
35+
throw;
36+
}
2837
}
2938
}
3039
}

Files/Views/ModernShellPage.xaml.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,15 @@ public async void CheckPathInput(ItemViewModel instance, string currentInput, st
491491
}
492492
}
493493

494-
if (!await Launcher.LaunchUriAsync(new Uri(currentInput)))
494+
try
495+
{
496+
if (!await Launcher.LaunchUriAsync(new Uri(currentInput)))
497+
{
498+
await DialogDisplayHelper.ShowDialog("InvalidItemDialogTitle".GetLocalized(),
499+
string.Format("InvalidItemDialogContent".GetLocalized(), Environment.NewLine, resFolder.ErrorCode.ToString()));
500+
}
501+
}
502+
catch (UriFormatException)
495503
{
496504
await DialogDisplayHelper.ShowDialog("InvalidItemDialogTitle".GetLocalized(),
497505
string.Format("InvalidItemDialogContent".GetLocalized(), Environment.NewLine, resFolder.ErrorCode.ToString()));

0 commit comments

Comments
 (0)