Refactor matrix-linkify module (#7279)

Refactor the module to make it easier for upgrade and proper separation of code contexts
This commit is contained in:
Dariusz Niemczyk 2021-12-03 15:00:56 +01:00 committed by GitHub
parent 3b9e39ffca
commit 961fec9081
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 99 additions and 206 deletions

View file

@ -13,14 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import * as linkifyjs from 'linkifyjs';
import Markdown from "../src/Markdown";
import matrixLinkify from '../src/linkify-matrix';
beforeAll(() => {
// We need to call linkifier plugins before running those tests
matrixLinkify(linkifyjs);
});
import Markdown from "../src/Markdown";
describe("Markdown parser test", () => {
describe("fixing HTML links", () => {

View file

@ -13,12 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import * as linkify from "linkifyjs";
import linkifyMatrix from '../src/linkify-matrix';
beforeAll(() => {
linkifyMatrix(linkify);
});
import { linkify } from '../src/linkify-matrix';
describe('linkify-matrix', () => {
describe('roomalias', () => {
@ -74,7 +69,6 @@ describe('linkify-matrix', () => {
href: "#foo:bar.com",
type: "roomalias",
value: "#foo:bar.com",
}]));
});
it('accept :NUM (port specifier)', () => {
@ -93,7 +87,6 @@ describe('linkify-matrix', () => {
href: "#foo:bar.com",
type: "roomalias",
value: "#foo:bar.com",
}]));
});
it('properly parses room alias with dots in name', () => {
@ -103,7 +96,6 @@ describe('linkify-matrix', () => {
href: "#foo.asdf:bar.com",
type: "roomalias",
value: "#foo.asdf:bar.com",
}]));
});
it('does not parse room alias with too many separators', () => {