|
1 |
| -using Flow.Launcher.Core.ExternalPlugins; |
2 |
| -using System; |
| 1 | +using System; |
3 | 2 | using System.Globalization;
|
4 | 3 | using System.IO;
|
5 |
| -using System.Text; |
6 | 4 | using System.Linq;
|
| 5 | +using System.Text; |
7 | 6 | using System.Windows;
|
8 | 7 | using System.Windows.Documents;
|
| 8 | +using Flow.Launcher.Core.ExternalPlugins; |
9 | 9 | using Flow.Launcher.Helper;
|
10 | 10 | using Flow.Launcher.Infrastructure;
|
11 |
| -using Flow.Launcher.Plugin.SharedCommands; |
12 | 11 | using Flow.Launcher.Infrastructure.UserSettings;
|
| 12 | +using Flow.Launcher.Plugin.SharedCommands; |
13 | 13 |
|
14 | 14 | namespace Flow.Launcher
|
15 | 15 | {
|
@@ -44,7 +44,7 @@ private void SetException(Exception exception)
|
44 | 44 |
|
45 | 45 | var websiteUrl = exception switch
|
46 | 46 | {
|
47 |
| - FlowPluginException pluginException =>GetIssuesUrl(pluginException.Metadata.Website), |
| 47 | + FlowPluginException pluginException => GetIssuesUrl(pluginException.Metadata.Website), |
48 | 48 | _ => Constant.IssuesUrl
|
49 | 49 | };
|
50 | 50 |
|
@@ -73,17 +73,36 @@ private static Paragraph Hyperlink(string textBeforeUrl, string url)
|
73 | 73 | Margin = new Thickness(0)
|
74 | 74 | };
|
75 | 75 |
|
76 |
| - var link = new Hyperlink |
| 76 | + Hyperlink link = null; |
| 77 | + try |
77 | 78 | {
|
78 |
| - IsEnabled = true |
79 |
| - }; |
80 |
| - link.Inlines.Add(url); |
81 |
| - link.NavigateUri = new Uri(url); |
82 |
| - link.Click += (s, e) => SearchWeb.OpenInBrowserTab(url); |
| 79 | + var uri = new Uri(url); |
| 80 | + |
| 81 | + link = new Hyperlink |
| 82 | + { |
| 83 | + IsEnabled = true |
| 84 | + }; |
| 85 | + link.Inlines.Add(url); |
| 86 | + link.NavigateUri = uri; |
| 87 | + link.Click += (s, e) => SearchWeb.OpenInBrowserTab(url); |
| 88 | + } |
| 89 | + catch (Exception) |
| 90 | + { |
| 91 | + // Leave link as null if the URL is invalid |
| 92 | + } |
83 | 93 |
|
84 | 94 | paragraph.Inlines.Add(textBeforeUrl);
|
85 | 95 | paragraph.Inlines.Add(" ");
|
86 |
| - paragraph.Inlines.Add(link); |
| 96 | + if (link is null) |
| 97 | + { |
| 98 | + // Add the URL as plain text if it is invalid |
| 99 | + paragraph.Inlines.Add(url); |
| 100 | + } |
| 101 | + else |
| 102 | + { |
| 103 | + // Add the hyperlink if it is valid |
| 104 | + paragraph.Inlines.Add(link); |
| 105 | + } |
87 | 106 | paragraph.Inlines.Add("\n");
|
88 | 107 |
|
89 | 108 | return paragraph;
|
|
0 commit comments