Update finite automate to match user identifiers as per spec (#10798)
This commit is contained in:
parent
dc9a00f280
commit
3692de0460
2 changed files with 19 additions and 1 deletions
|
@ -58,6 +58,8 @@ function matrixOpaqueIdLinkifyParser({
|
||||||
TLD,
|
TLD,
|
||||||
COLON,
|
COLON,
|
||||||
SYM,
|
SYM,
|
||||||
|
SLASH,
|
||||||
|
EQUALS,
|
||||||
HYPHEN,
|
HYPHEN,
|
||||||
UNDERSCORE,
|
UNDERSCORE,
|
||||||
// because 'localhost' is tokenised to the localhost token,
|
// because 'localhost' is tokenised to the localhost token,
|
||||||
|
@ -69,7 +71,7 @@ function matrixOpaqueIdLinkifyParser({
|
||||||
const S_START = parser.start;
|
const S_START = parser.start;
|
||||||
const matrixSymbol = utils.createTokenClass(name, { isLink: true });
|
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 domainpartTokens = [domain, TLD, LOCALHOST, HYPHEN];
|
||||||
|
|
||||||
const INITIAL_STATE = S_START.tt(token);
|
const INITIAL_STATE = S_START.tt(token);
|
||||||
|
|
|
@ -303,6 +303,22 @@ describe("linkify-matrix", () => {
|
||||||
|
|
||||||
describe("userid plugin", () => {
|
describe("userid plugin", () => {
|
||||||
genTests("@");
|
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", () => {
|
describe("matrix uri", () => {
|
||||||
|
|
Loading…
Reference in a new issue