Upgrade linkifyjs to fix schemes as domain prefixes (#7628)
This commit is contained in:
parent
fad65f9582
commit
51a44f491e
4 changed files with 33 additions and 10 deletions
|
@ -60,7 +60,7 @@
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.12.5",
|
||||||
"@matrix-org/linkify-element": "^4.0.0-rc.5",
|
"@matrix-org/linkify-element": "^4.0.0-rc.5",
|
||||||
"@matrix-org/linkify-string": "^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/browser": "^6.11.0",
|
||||||
"@sentry/tracing": "^6.11.0",
|
"@sentry/tracing": "^6.11.0",
|
||||||
"@types/geojson": "^7946.0.8",
|
"@types/geojson": "^7946.0.8",
|
||||||
|
|
|
@ -245,7 +245,7 @@ export const options = {
|
||||||
// Run the plugins
|
// Run the plugins
|
||||||
registerPlugin(Type.RoomAlias, ({ scanner, parser, utils }) => {
|
registerPlugin(Type.RoomAlias, ({ scanner, parser, utils }) => {
|
||||||
const token = scanner.tokens.POUND as '#';
|
const token = scanner.tokens.POUND as '#';
|
||||||
return matrixOpaqueIdLinkifyParser({
|
matrixOpaqueIdLinkifyParser({
|
||||||
scanner,
|
scanner,
|
||||||
parser,
|
parser,
|
||||||
utils,
|
utils,
|
||||||
|
@ -256,7 +256,7 @@ registerPlugin(Type.RoomAlias, ({ scanner, parser, utils }) => {
|
||||||
|
|
||||||
registerPlugin(Type.GroupId, ({ scanner, parser, utils }) => {
|
registerPlugin(Type.GroupId, ({ scanner, parser, utils }) => {
|
||||||
const token = scanner.tokens.PLUS as '+';
|
const token = scanner.tokens.PLUS as '+';
|
||||||
return matrixOpaqueIdLinkifyParser({
|
matrixOpaqueIdLinkifyParser({
|
||||||
scanner,
|
scanner,
|
||||||
parser,
|
parser,
|
||||||
utils,
|
utils,
|
||||||
|
@ -267,7 +267,7 @@ registerPlugin(Type.GroupId, ({ scanner, parser, utils }) => {
|
||||||
|
|
||||||
registerPlugin(Type.UserId, ({ scanner, parser, utils }) => {
|
registerPlugin(Type.UserId, ({ scanner, parser, utils }) => {
|
||||||
const token = scanner.tokens.AT as '@';
|
const token = scanner.tokens.AT as '@';
|
||||||
return matrixOpaqueIdLinkifyParser({
|
matrixOpaqueIdLinkifyParser({
|
||||||
scanner,
|
scanner,
|
||||||
parser,
|
parser,
|
||||||
utils,
|
utils,
|
||||||
|
|
|
@ -278,7 +278,7 @@ describe('linkify-matrix', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('matrix uri', () => {
|
describe('matrix uri', () => {
|
||||||
const AcceptedMatrixUris = [
|
const acceptedMatrixUris = [
|
||||||
'matrix:u/foo_bar:server.uk',
|
'matrix:u/foo_bar:server.uk',
|
||||||
'matrix:r/foo-bar:server.uk',
|
'matrix:r/foo-bar:server.uk',
|
||||||
'matrix:roomid/somewhere:example.org?via=elsewhere.ca',
|
'matrix:roomid/somewhere:example.org?via=elsewhere.ca',
|
||||||
|
@ -287,7 +287,7 @@ describe('linkify-matrix', () => {
|
||||||
'matrix:roomid/somewhere:example.org/e/event?via=elsewhere.ca',
|
'matrix:roomid/somewhere:example.org/e/event?via=elsewhere.ca',
|
||||||
'matrix:u/alice:example.org?action=chat',
|
'matrix:u/alice:example.org?action=chat',
|
||||||
];
|
];
|
||||||
for (const matrixUri of AcceptedMatrixUris) {
|
for (const matrixUri of acceptedMatrixUris) {
|
||||||
it('accepts ' + matrixUri, () => {
|
it('accepts ' + matrixUri, () => {
|
||||||
const test = matrixUri;
|
const test = matrixUri;
|
||||||
const found = linkify.find(test);
|
const found = linkify.find(test);
|
||||||
|
@ -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,
|
||||||
|
}]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1394,10 +1394,10 @@
|
||||||
resolved "https://registry.yarnpkg.com/@matrix-org/linkify-string/-/linkify-string-4.0.0-rc.5.tgz#139ba23c70a4f5b531656365a6109c122177b132"
|
resolved "https://registry.yarnpkg.com/@matrix-org/linkify-string/-/linkify-string-4.0.0-rc.5.tgz#139ba23c70a4f5b531656365a6109c122177b132"
|
||||||
integrity sha512-WFyu6+kVEPJsDwZwgCSrtUDeIMDdWIFzRRq5z+MLYHiO3J8G19jvRjRnNm4dwjDUqROWhvWS9b8JG7rbuwjkLQ==
|
integrity sha512-WFyu6+kVEPJsDwZwgCSrtUDeIMDdWIFzRRq5z+MLYHiO3J8G19jvRjRnNm4dwjDUqROWhvWS9b8JG7rbuwjkLQ==
|
||||||
|
|
||||||
"@matrix-org/linkifyjs@^4.0.0-rc.5":
|
"@matrix-org/linkifyjs@^4.0.0-rc.6":
|
||||||
version "4.0.0-rc.5"
|
version "4.0.0-rc.6"
|
||||||
resolved "https://registry.yarnpkg.com/@matrix-org/linkifyjs/-/linkifyjs-4.0.0-rc.5.tgz#3a2885754a8de51164a30e6e09909173e348d6bb"
|
resolved "https://registry.yarnpkg.com/@matrix-org/linkifyjs/-/linkifyjs-4.0.0-rc.6.tgz#62bce99272e0b2a78896b01651d8b26602247f32"
|
||||||
integrity sha512-HGmEZuUzCOzdsUFM5dQK2R2KhBFnxRfye5CYJhM2EpRTO4t5aTcR6Ey09HuJ/DZevQ9GTFUjkuKAKurQhnAfOA==
|
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":
|
"@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"
|
version "3.2.8"
|
||||||
|
|
Loading…
Reference in a new issue