Skip to content

Commit aae2ba6

Browse files
committed
fix(UrlOpening): Fix rare case where the URL doesn't open
Fixes SOUNDSWITCH-Y
1 parent 76e60a5 commit aae2ba6

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

SoundSwitch/Util/Url/BrowserUtil.cs

+10-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ public static void OpenUrl(string url)
1414
{
1515
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
1616
{
17-
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
17+
try
18+
{
19+
Process.Start(new ProcessStartInfo(url) {UseShellExecute = true});
20+
}
21+
catch (Exception)
22+
{
23+
url = url.Replace("&", "^&");
24+
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") {CreateNoWindow = true});
25+
}
1826
}
1927
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
2028
{
@@ -26,9 +34,8 @@ public static void OpenUrl(string url)
2634
}
2735
else
2836
{
29-
throw new ArgumentException("Unknown platform");
37+
throw new ArgumentException("Unknown platform");
3038
}
3139
}
32-
3340
}
3441
}

0 commit comments

Comments
 (0)