Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/MatrixReference/MatrixRoomReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
isStringRoomAlias,
isStringRoomID,
roomAliasServerName,
roomIDServerName,
} from "../StringlyTypedMatrix";
import { Permalinks } from "./Permalinks";
import { StringServerName } from "../StringlyTypedMatrix/StringServerName";
Expand Down Expand Up @@ -150,10 +149,6 @@ export class MatrixRoomID extends AbstractMatrixRoomReference {
public toRoomIDOrAlias(): StringRoomID {
return this.reference as StringRoomID;
}

public get serverName(): StringServerName {
return roomIDServerName(this.reference as StringRoomID);
}
}

/**
Expand Down
12 changes: 1 addition & 11 deletions src/StringlyTypedMatrix/StringRoomID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
// https://github.com/the-draupnir-project/matrix-basic-types
// </text>

import { StringServerName } from "./StringServerName";

const StringRoomIDRegex = /^![^:]*:(?<serverName>\S*)/;
const StringRoomIDRegex = /^!([^:]*:\S*|[a-zA-Z0-9-_]{43})/;

export type StringRoomIDBrand = {
readonly StringRoomID: unique symbol;
Expand All @@ -28,11 +26,3 @@ export function StringRoomID<T>(
}
throw new TypeError("Not a valid StringRoomID");
}

export function roomIDServerName(roomID: StringRoomID): StringServerName {
const match = StringRoomIDRegex.exec(roomID)?.groups?.serverName;
if (match === undefined) {
throw new TypeError("Somehow a StringRoomID was created that is invalid");
}
return match as StringServerName;
}
8 changes: 0 additions & 8 deletions src/StringlyTypedMatrix/StringlyTypedMatrix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import {
userLocalpart,
StringUserID,
isStringServerName,
roomIDServerName,
StringRoomID,
roomAliasServerName,
} from "./";

Expand All @@ -37,12 +35,6 @@ test("StringRoomID", function () {
expect(isStringRoomID("@foo:localhost:9999")).toBe(false);
});

test("StringRoomID serverName", function () {
expect(roomIDServerName(StringRoomID("!foo:localhost:9999"))).toBe(
"localhost:9999"
);
});

test("StringRoomAlias", function () {
expect(isStringRoomAlias("#foo:example.com")).toBe(true);
expect(isStringRoomAlias("!foo:example.com")).toBe(false);
Expand Down