Bypass external link dialog for links on the trusted osu! domain

This commit is contained in:
Dean Herbert 2024-05-30 16:39:53 +09:00
parent 87a331fdde
commit ed64bfff8d
No known key found for this signature in database
1 changed files with 12 additions and 3 deletions

View File

@ -485,10 +485,19 @@ public void HandleLink(LinkDetails link) => Schedule(() =>
}
});
public void OpenUrlExternally(string url, bool bypassExternalUrlWarning = false) => waitForReady(() => externalLinkOpener, _ =>
public void OpenUrlExternally(string url, bool forceBypassExternalUrlWarning = false) => waitForReady(() => externalLinkOpener, _ =>
{
bool isTrustedDomain;
if (url.StartsWith('/'))
url = $"{API.APIEndpointUrl}{url}";
{
url = $"{API.WebsiteRootUrl}{url}";
isTrustedDomain = true;
}
else
{
isTrustedDomain = url.StartsWith(API.APIEndpointUrl, StringComparison.Ordinal);
}
if (!url.CheckIsValidUrl())
{
@ -500,7 +509,7 @@ public void OpenUrlExternally(string url, bool bypassExternalUrlWarning = false)
return;
}
externalLinkOpener.OpenUrlExternally(url, bypassExternalUrlWarning);
externalLinkOpener.OpenUrlExternally(url, forceBypassExternalUrlWarning || isTrustedDomain);
});
/// <summary>