mirror of
https://github.com/Stone-Red-Code/Markdowser.git
synced 2026-09-04 09:06:15 +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 System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Markdowser.Commands;
|
||||
@@ -32,6 +34,22 @@ public class HyperlinkCommand : ICommand
|
||||
{
|
||||
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
|
||||
{
|
||||
GlobalState.Logger.LogDebug($"Invalid URL: {url}");
|
||||
|
||||
Reference in New Issue
Block a user