Fix MessageFormatter not working for custom endpoints

This commit is contained in:
Dean Herbert 2021-02-12 14:54:19 +09:00
parent cb4d119f23
commit 33c9ecac8a
2 changed files with 9 additions and 1 deletions

View File

@ -49,6 +49,11 @@ namespace osu.Game.Online.Chat
// Unicode emojis
private static readonly Regex emoji_regex = new Regex(@"(\uD83D[\uDC00-\uDE4F])");
/// <summary>
/// The root URL for the website, used for chat link matching.
/// </summary>
public static string WebsiteRootUrl { get; set; } = "https://osu.ppy.sh";
private static void handleMatches(Regex regex, string display, string link, MessageFormatterResult result, int startIndex = 0, LinkAction? linkActionOverride = null, char[] escapeChars = null)
{
int captureOffset = 0;
@ -119,7 +124,7 @@ namespace osu.Game.Online.Chat
case "http":
case "https":
// length > 3 since all these links need another argument to work
if (args.Length > 3 && args[1] == "osu.ppy.sh")
if (args.Length > 3 && url.StartsWith(WebsiteRootUrl, StringComparison.OrdinalIgnoreCase))
{
switch (args[2])
{

View File

@ -31,6 +31,7 @@ using osu.Game.Input;
using osu.Game.Input.Bindings;
using osu.Game.IO;
using osu.Game.Online;
using osu.Game.Online.Chat;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Spectator;
using osu.Game.Overlays;
@ -225,6 +226,8 @@ namespace osu.Game
EndpointConfiguration endpoints = UseDevelopmentServer ? (EndpointConfiguration)new DevelopmentEndpointConfiguration() : new ProductionEndpointConfiguration();
MessageFormatter.WebsiteRootUrl = endpoints.WebsiteRootUrl;
dependencies.CacheAs(API ??= new APIAccess(LocalConfig, endpoints));
dependencies.CacheAs(spectatorStreaming = new SpectatorStreamingClient(endpoints));