Fix the browser not opening on Linux.

This commit is contained in:
Milutinke 2022-08-20 19:06:51 +02:00
parent 0c0208ac49
commit 05c4661553

View file

@ -5,6 +5,7 @@ using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices;
namespace MinecraftClient.Protocol namespace MinecraftClient.Protocol
{ {
@ -91,7 +92,23 @@ namespace MinecraftClient.Protocol
{ {
try try
{ {
Process.Start(link); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
link = link.Replace("&", "^&");
Process.Start(new ProcessStartInfo(link) { UseShellExecute = true });
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Process.Start("xdg-open", link);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Process.Start("open", link);
}
else
{
ConsoleIO.WriteLine("Platform not supported, open up the link manually: " + link);
}
} }
catch (Exception e) catch (Exception e)
{ {