mirror of https://github.com/ppy/osu
parent
111bfd4d88
commit
a9f4bc6285
|
@ -24,10 +24,10 @@ public void TestBareLink()
|
||||||
[TestCase(LinkAction.OpenBeatmap, "456", "https://dev.ppy.sh/beatmapsets/123#osu/456")]
|
[TestCase(LinkAction.OpenBeatmap, "456", "https://dev.ppy.sh/beatmapsets/123#osu/456")]
|
||||||
[TestCase(LinkAction.OpenBeatmap, "456", "https://dev.ppy.sh/beatmapsets/123#osu/456?whatever")]
|
[TestCase(LinkAction.OpenBeatmap, "456", "https://dev.ppy.sh/beatmapsets/123#osu/456?whatever")]
|
||||||
[TestCase(LinkAction.OpenBeatmap, "456", "https://dev.ppy.sh/beatmapsets/123/456")]
|
[TestCase(LinkAction.OpenBeatmap, "456", "https://dev.ppy.sh/beatmapsets/123/456")]
|
||||||
[TestCase(LinkAction.External, null, "https://dev.ppy.sh/beatmapsets/abc/def")]
|
[TestCase(LinkAction.External, "https://dev.ppy.sh/beatmapsets/abc/def", "https://dev.ppy.sh/beatmapsets/abc/def")]
|
||||||
[TestCase(LinkAction.OpenBeatmapSet, "123", "https://dev.ppy.sh/beatmapsets/123")]
|
[TestCase(LinkAction.OpenBeatmapSet, "123", "https://dev.ppy.sh/beatmapsets/123")]
|
||||||
[TestCase(LinkAction.OpenBeatmapSet, "123", "https://dev.ppy.sh/beatmapsets/123/whatever")]
|
[TestCase(LinkAction.OpenBeatmapSet, "123", "https://dev.ppy.sh/beatmapsets/123/whatever")]
|
||||||
[TestCase(LinkAction.External, null, "https://dev.ppy.sh/beatmapsets/abc")]
|
[TestCase(LinkAction.External, "https://dev.ppy.sh/beatmapsets/abc", "https://dev.ppy.sh/beatmapsets/abc")]
|
||||||
public void TestBeatmapLinks(LinkAction expectedAction, string expectedArg, string link)
|
public void TestBeatmapLinks(LinkAction expectedAction, string expectedArg, string link)
|
||||||
{
|
{
|
||||||
MessageFormatter.WebsiteRootUrl = "dev.ppy.sh";
|
MessageFormatter.WebsiteRootUrl = "dev.ppy.sh";
|
||||||
|
@ -490,6 +490,15 @@ public void TestEmoji()
|
||||||
Assert.AreEqual(result.Links[3].Url, "\uD83D\uDE20");
|
Assert.AreEqual(result.Links[3].Url, "\uD83D\uDE20");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAbsoluteExternalLinks()
|
||||||
|
{
|
||||||
|
LinkDetails result = MessageFormatter.GetLinkDetails("https://google.com");
|
||||||
|
|
||||||
|
Assert.AreEqual(LinkAction.External, result.Action);
|
||||||
|
Assert.AreEqual("https://google.com", result.Argument);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestRelativeExternalLinks()
|
public void TestRelativeExternalLinks()
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
namespace osu.Game.Online.Chat
|
namespace osu.Game.Online.Chat
|
||||||
{
|
{
|
||||||
public static class MessageFormatter
|
public static class MessageFormatter
|
||||||
|
@ -61,7 +63,7 @@ public static string WebsiteRootUrl
|
||||||
|
|
||||||
private static string websiteRootUrl = "osu.ppy.sh";
|
private static string websiteRootUrl = "osu.ppy.sh";
|
||||||
|
|
||||||
private static void handleMatches(Regex regex, string display, string link, MessageFormatterResult result, int startIndex = 0, LinkAction? linkActionOverride = null, char[] escapeChars = null)
|
private static void handleMatches(Regex regex, string display, string link, MessageFormatterResult result, int startIndex = 0, LinkAction? linkActionOverride = null, char[]? escapeChars = null)
|
||||||
{
|
{
|
||||||
int captureOffset = 0;
|
int captureOffset = 0;
|
||||||
|
|
||||||
|
@ -170,12 +172,12 @@ public static LinkDetails GetLinkDetails(string url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LinkDetails(LinkAction.External, null);
|
break;
|
||||||
|
|
||||||
case "osu":
|
case "osu":
|
||||||
// every internal link also needs some kind of argument
|
// every internal link also needs some kind of argument
|
||||||
if (args.Length < 3)
|
if (args.Length < 3)
|
||||||
return new LinkDetails(LinkAction.External, null);
|
break;
|
||||||
|
|
||||||
LinkAction linkType;
|
LinkAction linkType;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue