Skip to content

Commit 7aaecb8

Browse files
fix link capturing group
so they dont capture sentences with dots at the end
1 parent f4a727a commit 7aaecb8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

JitsiMeetOutlook/Utils.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static void RunInThread(Action function)
6565
public static List<KeyValuePair<bool, string>> SplitToTextAndHyperlinks(string text)
6666
{
6767
var list = new List<KeyValuePair<bool, string>>();
68-
MatchCollection matches = Regex.Matches(text, "http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+");
68+
MatchCollection matches = Regex.Matches(text, "http[s]?:\\/\\/(?:[a-zA-Z]|[0-9]|[$-_@&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+(?<!\\.)");
6969
if (matches.Count == 0)
7070
{
7171
list.Add(new KeyValuePair<bool, string>(false, text));

JitsiMeetOutlookTests/TextUtilsTests.cs

+12
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,19 @@ public void SplitToTextAndHyperlinksEmpty()
8888
new KeyValuePair<bool, string>( false, "test with no links everywhere interesting end")
8989

9090
});
91+
}
9192

93+
[TestMethod()]
94+
public void SplitToTextAndHyperlinksSpecialCharacter()
95+
{
96+
var text = "test with no links everywhere interesting end https://cool.link.";
97+
List<KeyValuePair<bool, string>> split = Utils.SplitToTextAndHyperlinks(text);
98+
split.Should().Equal(new List<KeyValuePair<bool, string>>()
99+
{
100+
new KeyValuePair<bool, string>( false, "test with no links everywhere interesting end "),
101+
new KeyValuePair<bool, string>( true, "https://cool.link"),
102+
new KeyValuePair<bool, string>( false, "."),
103+
});
92104
}
93105
}
94106
}

0 commit comments

Comments
 (0)