Skip to content

Commit

Permalink
fix(UrlOpening): Fix rare case where the URL doesn't open
Browse files Browse the repository at this point in the history
Fixes SOUNDSWITCH-Y
  • Loading branch information
Belphemur committed May 8, 2021
1 parent 76e60a5 commit aae2ba6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions SoundSwitch/Util/Url/BrowserUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ public static void OpenUrl(string url)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
try
{
Process.Start(new ProcessStartInfo(url) {UseShellExecute = true});
}
catch (Exception)
{
url = url.Replace("&", "^&");
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") {CreateNoWindow = true});
}
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
Expand All @@ -26,9 +34,8 @@ public static void OpenUrl(string url)
}
else
{
throw new ArgumentException("Unknown platform");
throw new ArgumentException("Unknown platform");
}
}

}
}

0 comments on commit aae2ba6

Please sign in to comment.