Skip to content

Commit 1bd7f5a

Browse files
Jack251970TBM13
authored andcommitted
Merge pull request Flow-Launcher#3851 from Flow-Launcher/url_exception
Fix uri exception in Report window
1 parent 98056ad commit 1bd7f5a

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

Flow.Launcher/ReportWindow.xaml.cs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,36 @@ private static Paragraph Hyperlink(string textBeforeUrl, string url)
6868
Margin = new Thickness(0)
6969
};
7070

71-
var link = new Hyperlink
71+
Hyperlink link = null;
72+
try
7273
{
73-
IsEnabled = true
74-
};
75-
link.Inlines.Add(url);
76-
link.NavigateUri = new Uri(url);
77-
link.Click += (s, e) => SearchWeb.OpenInBrowserTab(url);
74+
var uri = new Uri(url);
75+
76+
link = new Hyperlink
77+
{
78+
IsEnabled = true
79+
};
80+
link.Inlines.Add(url);
81+
link.NavigateUri = uri;
82+
link.Click += (s, e) => SearchWeb.OpenInBrowserTab(url);
83+
}
84+
catch (Exception)
85+
{
86+
// Leave link as null if the URL is invalid
87+
}
7888

7989
paragraph.Inlines.Add(textBeforeUrl);
8090
paragraph.Inlines.Add(" ");
81-
paragraph.Inlines.Add(link);
91+
if (link is null)
92+
{
93+
// Add the URL as plain text if it is invalid
94+
paragraph.Inlines.Add(url);
95+
}
96+
else
97+
{
98+
// Add the hyperlink if it is valid
99+
paragraph.Inlines.Add(link);
100+
}
82101
paragraph.Inlines.Add("\n");
83102

84103
return paragraph;

0 commit comments

Comments
 (0)