Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 3692de0

Browse files
authored
Update finite automate to match user identifiers as per spec (#10798)
1 parent dc9a00f commit 3692de0

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/linkify-matrix.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ function matrixOpaqueIdLinkifyParser({
5858
TLD,
5959
COLON,
6060
SYM,
61+
SLASH,
62+
EQUALS,
6163
HYPHEN,
6264
UNDERSCORE,
6365
// because 'localhost' is tokenised to the localhost token,
@@ -69,7 +71,7 @@ function matrixOpaqueIdLinkifyParser({
6971
const S_START = parser.start;
7072
const matrixSymbol = utils.createTokenClass(name, { isLink: true });
7173

72-
const localpartTokens = [domain, TLD, LOCALHOST, SYM, UNDERSCORE, HYPHEN];
74+
const localpartTokens = [domain, TLD, DOT, LOCALHOST, SYM, SLASH, EQUALS, UNDERSCORE, HYPHEN];
7375
const domainpartTokens = [domain, TLD, LOCALHOST, HYPHEN];
7476

7577
const INITIAL_STATE = S_START.tt(token);

test/linkify-matrix-test.ts

+16
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,22 @@ describe("linkify-matrix", () => {
303303

304304
describe("userid plugin", () => {
305305
genTests("@");
306+
307+
it("allows dots in localparts", () => {
308+
const test = "@test.:matrix.org";
309+
const found = linkify.find(test);
310+
expect(found).toEqual([
311+
{
312+
href: test,
313+
type: "userid",
314+
value: test,
315+
start: 0,
316+
end: test.length,
317+
318+
isLink: true,
319+
},
320+
]);
321+
});
306322
});
307323

308324
describe("matrix uri", () => {

0 commit comments

Comments
 (0)