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

Commit

Permalink
Upgrade linkifyjs to fix schemes as domain prefixes (#7628)
Browse files Browse the repository at this point in the history
  • Loading branch information
jryans authored Jan 25, 2022
1 parent fad65f9 commit 51a44f4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@babel/runtime": "^7.12.5",
"@matrix-org/linkify-element": "^4.0.0-rc.5",
"@matrix-org/linkify-string": "^4.0.0-rc.5",
"@matrix-org/linkifyjs": "^4.0.0-rc.5",
"@matrix-org/linkifyjs": "^4.0.0-rc.6",
"@sentry/browser": "^6.11.0",
"@sentry/tracing": "^6.11.0",
"@types/geojson": "^7946.0.8",
Expand Down
6 changes: 3 additions & 3 deletions src/linkify-matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export const options = {
// Run the plugins
registerPlugin(Type.RoomAlias, ({ scanner, parser, utils }) => {
const token = scanner.tokens.POUND as '#';
return matrixOpaqueIdLinkifyParser({
matrixOpaqueIdLinkifyParser({
scanner,
parser,
utils,
Expand All @@ -256,7 +256,7 @@ registerPlugin(Type.RoomAlias, ({ scanner, parser, utils }) => {

registerPlugin(Type.GroupId, ({ scanner, parser, utils }) => {
const token = scanner.tokens.PLUS as '+';
return matrixOpaqueIdLinkifyParser({
matrixOpaqueIdLinkifyParser({
scanner,
parser,
utils,
Expand All @@ -267,7 +267,7 @@ registerPlugin(Type.GroupId, ({ scanner, parser, utils }) => {

registerPlugin(Type.UserId, ({ scanner, parser, utils }) => {
const token = scanner.tokens.AT as '@';
return matrixOpaqueIdLinkifyParser({
matrixOpaqueIdLinkifyParser({
scanner,
parser,
utils,
Expand Down
27 changes: 25 additions & 2 deletions test/linkify-matrix-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ describe('linkify-matrix', () => {
});

describe('matrix uri', () => {
const AcceptedMatrixUris = [
const acceptedMatrixUris = [
'matrix:u/foo_bar:server.uk',
'matrix:r/foo-bar:server.uk',
'matrix:roomid/somewhere:example.org?via=elsewhere.ca',
Expand All @@ -287,7 +287,7 @@ describe('linkify-matrix', () => {
'matrix:roomid/somewhere:example.org/e/event?via=elsewhere.ca',
'matrix:u/alice:example.org?action=chat',
];
for (const matrixUri of AcceptedMatrixUris) {
for (const matrixUri of acceptedMatrixUris) {
it('accepts ' + matrixUri, () => {
const test = matrixUri;
const found = linkify.find(test);
Expand All @@ -302,4 +302,27 @@ describe('linkify-matrix', () => {
});
}
});

describe("matrix-prefixed domains", () => {
const acceptedDomains = [
'matrix.org',
'matrix.to',
'matrix-help.org',
'matrix123.org',
];
for (const domain of acceptedDomains) {
it('accepts ' + domain, () => {
const test = domain;
const found = linkify.find(test);
expect(found).toEqual(([{
href: `http://${domain}`,
type: Type.URL,
value: domain,
end: domain.length,
start: 0,
isLink: true,
}]));
});
}
});
});
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1394,10 +1394,10 @@
resolved "https://registry.yarnpkg.com/@matrix-org/linkify-string/-/linkify-string-4.0.0-rc.5.tgz#139ba23c70a4f5b531656365a6109c122177b132"
integrity sha512-WFyu6+kVEPJsDwZwgCSrtUDeIMDdWIFzRRq5z+MLYHiO3J8G19jvRjRnNm4dwjDUqROWhvWS9b8JG7rbuwjkLQ==

"@matrix-org/linkifyjs@^4.0.0-rc.5":
version "4.0.0-rc.5"
resolved "https://registry.yarnpkg.com/@matrix-org/linkifyjs/-/linkifyjs-4.0.0-rc.5.tgz#3a2885754a8de51164a30e6e09909173e348d6bb"
integrity sha512-HGmEZuUzCOzdsUFM5dQK2R2KhBFnxRfye5CYJhM2EpRTO4t5aTcR6Ey09HuJ/DZevQ9GTFUjkuKAKurQhnAfOA==
"@matrix-org/linkifyjs@^4.0.0-rc.6":
version "4.0.0-rc.6"
resolved "https://registry.yarnpkg.com/@matrix-org/linkifyjs/-/linkifyjs-4.0.0-rc.6.tgz#62bce99272e0b2a78896b01651d8b26602247f32"
integrity sha512-RoBejrxlv8jJjaZ9itTx0+JW8ECNEvj7iJzbD1rGhToLZjRZ5qXexWIa3+Vu4qmm+Yic+ETPCSH7odYWSYj/fA==

"@matrix-org/olm@https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz":
version "3.2.8"
Expand Down

0 comments on commit 51a44f4

Please sign in to comment.