mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 07:33:22 +08:00
Remove unnecessary paren handling from regex
Can't find a reason for this to exist
This commit is contained in:
parent
662c7c5bdc
commit
d81d884a01
@ -25,7 +25,6 @@ namespace osu.Game.Online.Chat
|
|||||||
// This is in the format (<required>, [optional]):
|
// This is in the format (<required>, [optional]):
|
||||||
// http[s]://<domain>.<tld>[:port][/path][?query][#fragment]
|
// http[s]://<domain>.<tld>[:port][/path][?query][#fragment]
|
||||||
private static readonly Regex advanced_link_regex = new Regex(
|
private static readonly Regex advanced_link_regex = new Regex(
|
||||||
@"(?<paren>\([^)]*)?" +
|
|
||||||
// protocol
|
// protocol
|
||||||
@"(?<link>[a-z]*?:\/\/" +
|
@"(?<link>[a-z]*?:\/\/" +
|
||||||
// domain + tld
|
// domain + tld
|
||||||
@ -90,20 +89,9 @@ namespace osu.Game.Online.Chat
|
|||||||
foreach (Match m in regex.Matches(result.Text, startIndex))
|
foreach (Match m in regex.Matches(result.Text, startIndex))
|
||||||
{
|
{
|
||||||
var index = m.Index;
|
var index = m.Index;
|
||||||
var prefix = m.Groups["paren"].Value;
|
|
||||||
var link = m.Groups["link"].Value;
|
var link = m.Groups["link"].Value;
|
||||||
var indexLength = link.Length;
|
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);
|
var details = getLinkDetails(link);
|
||||||
result.Links.Add(new Link(link, index, indexLength, details.Action, details.Argument));
|
result.Links.Add(new Link(link, index, indexLength, details.Action, details.Argument));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user