JavaScript / TypeScript parser for the URI scheme of the Matrix chat protocol.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Bruno Windels 506c2545da
Merge pull request #1 from matrix-org/bwindels-patch-1
mark as a es module package
2021-09-28 14:07:18 +02:00
src Fix offset in substring code 2021-08-27 14:46:46 -07:00
package.json mark as a es module package 2021-09-28 12:06:58 +00:00
README.md Update README.md 2021-09-27 13:59:01 +00:00
tsconfig.json Add tsconfig 2021-08-23 16:46:00 -07:00
yarn.lock Add impunity and write tests 2021-08-27 14:28:37 -07:00

matrix-uri-parser-js

This is still work in progress.

JavaScript / TypeScript parser for the URI scheme of the Matrix chat protocol.

Usage

The package exposes a class, MatrixURL, whose constructor accepts s string (the URI to parse).

import {MatrixURL, EntityType} from "matrix-uri-parser";
import assert from 'assert/strict';

const result = new MatrixURL("matrix:roomid/rid:example.org/event/lol823y4bcp3qo4?via=example2.org");
assert.equal(result.kind, EntityType.RoomId);
assert.equal(result.id, "rid:example.org");
assert.equal(result.eventId, "lol823y4bcp3qo4");
assert.deepEqual(result.via, ["example2.org"]);