mirror of
https://github.com/Stone-Red-Code/Markdowser.git
synced 2026-09-09 07:46:29 +02:00
Try to open file if hyper link does not contain a valid URL
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
using Markdowser.Utilities;
|
using Markdowser.Utilities;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace Markdowser.Commands;
|
namespace Markdowser.Commands;
|
||||||
@@ -32,6 +34,22 @@ public class HyperlinkCommand : ICommand
|
|||||||
{
|
{
|
||||||
GlobalState.CurrentTabState.Url = new Uri(new Uri(GlobalState.CurrentTabState.Url), url).ToString();
|
GlobalState.CurrentTabState.Url = new Uri(new Uri(GlobalState.CurrentTabState.Url), url).ToString();
|
||||||
}
|
}
|
||||||
|
else if (File.Exists(url))
|
||||||
|
{
|
||||||
|
ProcessStartInfo processStartInfo = new()
|
||||||
|
{
|
||||||
|
FileName = url,
|
||||||
|
UseShellExecute = true
|
||||||
|
};
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_ = Process.Start(processStartInfo);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalState.Logger.LogError(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GlobalState.Logger.LogDebug($"Invalid URL: {url}");
|
GlobalState.Logger.LogDebug($"Invalid URL: {url}");
|
||||||
|
|||||||
Reference in New Issue
Block a user