From 05c466155397cb9c36ddbe79576a78507b0bbacb Mon Sep 17 00:00:00 2001 From: Milutinke Date: Sat, 20 Aug 2022 19:06:51 +0200 Subject: [PATCH] Fix the browser not opening on Linux. --- .../Protocol/MicrosoftAuthentication.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/MinecraftClient/Protocol/MicrosoftAuthentication.cs b/MinecraftClient/Protocol/MicrosoftAuthentication.cs index ec551713..6b487c07 100644 --- a/MinecraftClient/Protocol/MicrosoftAuthentication.cs +++ b/MinecraftClient/Protocol/MicrosoftAuthentication.cs @@ -5,6 +5,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Collections.Specialized; using System.Diagnostics; +using System.Runtime.InteropServices; namespace MinecraftClient.Protocol { @@ -91,7 +92,23 @@ namespace MinecraftClient.Protocol { 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) {