[parsing] Allow usernames starting & ending with an underscore
This commit is contained in:
parent
adba960f8c
commit
91544cdd78
2 changed files with 12 additions and 3 deletions
|
@ -228,7 +228,8 @@ module private MfmParser =
|
||||||
>>. skipString "@"
|
>>. skipString "@"
|
||||||
>>. many1Chars (
|
>>. many1Chars (
|
||||||
satisfy isAsciiLetterOrNumber
|
satisfy isAsciiLetterOrNumber
|
||||||
<|> attempt (anyOf "._-" .>> nextCharSatisfies isAsciiLetterOrNumber)
|
<|> pchar '_'
|
||||||
|
<|> attempt (anyOf ".-" .>> nextCharSatisfies isAsciiLetterOrNumber)
|
||||||
)
|
)
|
||||||
.>>. opt (skipChar '@' >>. domain)
|
.>>. opt (skipChar '@' >>. domain)
|
||||||
.>> (lookAhead
|
.>> (lookAhead
|
||||||
|
|
|
@ -66,13 +66,21 @@ public class MfmTests
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMention()
|
public void TestMention()
|
||||||
{
|
{
|
||||||
const string input = "test @test test @test@instance.tld";
|
const string input = "test @test test @test@instance.tld @test_ @_test @test_@instance.tld @_test@instance.tld";
|
||||||
List<MfmNode> expected =
|
List<MfmNode> expected =
|
||||||
[
|
[
|
||||||
new MfmTextNode("test "),
|
new MfmTextNode("test "),
|
||||||
new MfmMentionNode("test", "test", null),
|
new MfmMentionNode("test", "test", null),
|
||||||
new MfmTextNode(" test "),
|
new MfmTextNode(" test "),
|
||||||
new MfmMentionNode("test@instance.tld", "test", "instance.tld")
|
new MfmMentionNode("test@instance.tld", "test", "instance.tld"),
|
||||||
|
new MfmTextNode(" "),
|
||||||
|
new MfmMentionNode("test_", "test_", null),
|
||||||
|
new MfmTextNode(" "),
|
||||||
|
new MfmMentionNode("_test", "_test", null),
|
||||||
|
new MfmTextNode(" "),
|
||||||
|
new MfmMentionNode("test_@instance.tld", "test_", "instance.tld"),
|
||||||
|
new MfmTextNode(" "),
|
||||||
|
new MfmMentionNode("_test@instance.tld", "_test", "instance.tld"),
|
||||||
];
|
];
|
||||||
var res = Mfm.parse(input);
|
var res = Mfm.parse(input);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue