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

Commit 51a44f4

Browse files
authored
Upgrade linkifyjs to fix schemes as domain prefixes (#7628)
1 parent fad65f9 commit 51a44f4

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"@babel/runtime": "^7.12.5",
6161
"@matrix-org/linkify-element": "^4.0.0-rc.5",
6262
"@matrix-org/linkify-string": "^4.0.0-rc.5",
63-
"@matrix-org/linkifyjs": "^4.0.0-rc.5",
63+
"@matrix-org/linkifyjs": "^4.0.0-rc.6",
6464
"@sentry/browser": "^6.11.0",
6565
"@sentry/tracing": "^6.11.0",
6666
"@types/geojson": "^7946.0.8",

src/linkify-matrix.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export const options = {
245245
// Run the plugins
246246
registerPlugin(Type.RoomAlias, ({ scanner, parser, utils }) => {
247247
const token = scanner.tokens.POUND as '#';
248-
return matrixOpaqueIdLinkifyParser({
248+
matrixOpaqueIdLinkifyParser({
249249
scanner,
250250
parser,
251251
utils,
@@ -256,7 +256,7 @@ registerPlugin(Type.RoomAlias, ({ scanner, parser, utils }) => {
256256

257257
registerPlugin(Type.GroupId, ({ scanner, parser, utils }) => {
258258
const token = scanner.tokens.PLUS as '+';
259-
return matrixOpaqueIdLinkifyParser({
259+
matrixOpaqueIdLinkifyParser({
260260
scanner,
261261
parser,
262262
utils,
@@ -267,7 +267,7 @@ registerPlugin(Type.GroupId, ({ scanner, parser, utils }) => {
267267

268268
registerPlugin(Type.UserId, ({ scanner, parser, utils }) => {
269269
const token = scanner.tokens.AT as '@';
270-
return matrixOpaqueIdLinkifyParser({
270+
matrixOpaqueIdLinkifyParser({
271271
scanner,
272272
parser,
273273
utils,

test/linkify-matrix-test.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ describe('linkify-matrix', () => {
278278
});
279279

280280
describe('matrix uri', () => {
281-
const AcceptedMatrixUris = [
281+
const acceptedMatrixUris = [
282282
'matrix:u/foo_bar:server.uk',
283283
'matrix:r/foo-bar:server.uk',
284284
'matrix:roomid/somewhere:example.org?via=elsewhere.ca',
@@ -287,7 +287,7 @@ describe('linkify-matrix', () => {
287287
'matrix:roomid/somewhere:example.org/e/event?via=elsewhere.ca',
288288
'matrix:u/alice:example.org?action=chat',
289289
];
290-
for (const matrixUri of AcceptedMatrixUris) {
290+
for (const matrixUri of acceptedMatrixUris) {
291291
it('accepts ' + matrixUri, () => {
292292
const test = matrixUri;
293293
const found = linkify.find(test);
@@ -302,4 +302,27 @@ describe('linkify-matrix', () => {
302302
});
303303
}
304304
});
305+
306+
describe("matrix-prefixed domains", () => {
307+
const acceptedDomains = [
308+
'matrix.org',
309+
'matrix.to',
310+
'matrix-help.org',
311+
'matrix123.org',
312+
];
313+
for (const domain of acceptedDomains) {
314+
it('accepts ' + domain, () => {
315+
const test = domain;
316+
const found = linkify.find(test);
317+
expect(found).toEqual(([{
318+
href: `http://${domain}`,
319+
type: Type.URL,
320+
value: domain,
321+
end: domain.length,
322+
start: 0,
323+
isLink: true,
324+
}]));
325+
});
326+
}
327+
});
305328
});

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,10 +1394,10 @@
13941394
resolved "https://registry.yarnpkg.com/@matrix-org/linkify-string/-/linkify-string-4.0.0-rc.5.tgz#139ba23c70a4f5b531656365a6109c122177b132"
13951395
integrity sha512-WFyu6+kVEPJsDwZwgCSrtUDeIMDdWIFzRRq5z+MLYHiO3J8G19jvRjRnNm4dwjDUqROWhvWS9b8JG7rbuwjkLQ==
13961396

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

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

0 commit comments

Comments
 (0)