1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Remove unnecessary paren handling from regex

Can't find a reason for this to exist
This commit is contained in:
Dean Herbert 2018-01-30 17:16:01 +09:00
parent 662c7c5bdc
commit d81d884a01

View File

@ -25,7 +25,6 @@ namespace osu.Game.Online.Chat
// This is in the format (<required>, [optional]):
// http[s]://<domain>.<tld>[:port][/path][?query][#fragment]
private static readonly Regex advanced_link_regex = new Regex(
@"(?<paren>\([^)]*)?" +
// protocol
@"(?<link>[a-z]*?:\/\/" +
// domain + tld
@ -90,20 +89,9 @@ namespace osu.Game.Online.Chat
foreach (Match m in regex.Matches(result.Text, startIndex))
{
var index = m.Index;
var prefix = m.Groups["paren"].Value;
var link = m.Groups["link"].Value;
var indexLength = link.Length;
if (!String.IsNullOrEmpty(prefix))
{
index += prefix.Length;
if (link.EndsWith(")"))
{
indexLength = indexLength - 1;
link = link.Remove(link.Length - 1);
}
}
var details = getLinkDetails(link);
result.Links.Add(new Link(link, index, indexLength, details.Action, details.Argument));
}