mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 06:36:31 +09:00
Change containment check to overlap
Due to scenarios wherein a formatted link ended up as part of a larger raw link after parsing, change the containment check to an overlap check and add appropriate tests for these edge cases.
This commit is contained in:
@ -104,7 +104,7 @@ namespace osu.Game.Online.Chat
|
||||
// sometimes an already-processed formatted link can reduce to a simple URL, too
|
||||
// (example: [mean example - https://osu.ppy.sh](https://osu.ppy.sh))
|
||||
// therefore we need to check if any of the pre-existing links contains the raw one we found
|
||||
if (result.Links.All(existingLink => !existingLink.Contains(link)))
|
||||
if (result.Links.All(existingLink => !existingLink.Overlaps(link)))
|
||||
result.Links.Add(link);
|
||||
}
|
||||
}
|
||||
@ -298,7 +298,7 @@ namespace osu.Game.Online.Chat
|
||||
Argument = argument;
|
||||
}
|
||||
|
||||
public bool Contains(Link otherLink) => otherLink.Index >= Index && otherLink.Index + otherLink.Length <= Index + Length;
|
||||
public bool Overlaps(Link otherLink) => Index < otherLink.Index + otherLink.Length && otherLink.Index < Index + Length;
|
||||
|
||||
public int CompareTo(Link otherLink) => Index > otherLink.Index ? 1 : -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user