diff --git a/src/MatrixReference/MatrixRoomReference.ts b/src/MatrixReference/MatrixRoomReference.ts index d19ebab..c83a8e4 100644 --- a/src/MatrixReference/MatrixRoomReference.ts +++ b/src/MatrixReference/MatrixRoomReference.ts @@ -15,7 +15,6 @@ import { isStringRoomAlias, isStringRoomID, roomAliasServerName, - roomIDServerName, } from "../StringlyTypedMatrix"; import { Permalinks } from "./Permalinks"; import { StringServerName } from "../StringlyTypedMatrix/StringServerName"; @@ -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); - } } /** diff --git a/src/StringlyTypedMatrix/StringRoomID.ts b/src/StringlyTypedMatrix/StringRoomID.ts index aab16ca..d1c7346 100644 --- a/src/StringlyTypedMatrix/StringRoomID.ts +++ b/src/StringlyTypedMatrix/StringRoomID.ts @@ -7,9 +7,7 @@ // https://github.com/the-draupnir-project/matrix-basic-types // -import { StringServerName } from "./StringServerName"; - -const StringRoomIDRegex = /^![^:]*:(?\S*)/; +const StringRoomIDRegex = /^!([^:]*:\S*|[a-zA-Z0-9-_]{43})/; export type StringRoomIDBrand = { readonly StringRoomID: unique symbol; @@ -28,11 +26,3 @@ export function StringRoomID( } 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; -} diff --git a/src/StringlyTypedMatrix/StringlyTypedMatrix.test.ts b/src/StringlyTypedMatrix/StringlyTypedMatrix.test.ts index 25b3482..859d902 100644 --- a/src/StringlyTypedMatrix/StringlyTypedMatrix.test.ts +++ b/src/StringlyTypedMatrix/StringlyTypedMatrix.test.ts @@ -11,8 +11,6 @@ import { userLocalpart, StringUserID, isStringServerName, - roomIDServerName, - StringRoomID, roomAliasServerName, } from "./"; @@ -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);