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

Commit

Permalink
Update finite automate to match user identifiers as per spec (#10798)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored May 9, 2023
1 parent dc9a00f commit 3692de0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/linkify-matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ function matrixOpaqueIdLinkifyParser({
TLD,
COLON,
SYM,
SLASH,
EQUALS,
HYPHEN,
UNDERSCORE,
// because 'localhost' is tokenised to the localhost token,
Expand All @@ -69,7 +71,7 @@ function matrixOpaqueIdLinkifyParser({
const S_START = parser.start;
const matrixSymbol = utils.createTokenClass(name, { isLink: true });

const localpartTokens = [domain, TLD, LOCALHOST, SYM, UNDERSCORE, HYPHEN];
const localpartTokens = [domain, TLD, DOT, LOCALHOST, SYM, SLASH, EQUALS, UNDERSCORE, HYPHEN];
const domainpartTokens = [domain, TLD, LOCALHOST, HYPHEN];

const INITIAL_STATE = S_START.tt(token);
Expand Down
16 changes: 16 additions & 0 deletions test/linkify-matrix-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,22 @@ describe("linkify-matrix", () => {

describe("userid plugin", () => {
genTests("@");

it("allows dots in localparts", () => {
const test = "@test.:matrix.org";
const found = linkify.find(test);
expect(found).toEqual([
{
href: test,
type: "userid",
value: test,
start: 0,
end: test.length,

isLink: true,
},
]);
});
});

describe("matrix uri", () => {
Expand Down

0 comments on commit 3692de0

Please sign in to comment.