diff --git a/src/commands/interface-manager/CommandReader.ts b/src/commands/interface-manager/CommandReader.ts index 283834ec..45f46767 100644 --- a/src/commands/interface-manager/CommandReader.ts +++ b/src/commands/interface-manager/CommandReader.ts @@ -210,7 +210,7 @@ function readRoomIDOrAlias(stream: StringStream): MatrixRoomReference|string { } readUntil(/\s/, stream, word); const wholeWord = word.join(''); - if (!isStringRoomID(wholeWord) || !isStringRoomAlias(wholeWord)) { + if (!isStringRoomID(wholeWord) && !isStringRoomAlias(wholeWord)) { return wholeWord; } return MatrixRoomReference.fromRoomIDOrAlias(wholeWord); diff --git a/test/commands/CommandReaderTest.ts b/test/commands/CommandReaderTest.ts index 15133e29..143f717d 100644 --- a/test/commands/CommandReaderTest.ts +++ b/test/commands/CommandReaderTest.ts @@ -1,6 +1,6 @@ import expect from "expect"; import { Keyword, readCommand, ReadItem } from "../../src/commands/interface-manager/CommandReader"; -import { MatrixRoomReference } from "../../src/commands/interface-manager/MatrixRoomReference"; +import { MatrixRoomAlias, MatrixRoomID, MatrixRoomReference } from "matrix-protection-suite"; describe("Can read", function() { it("Can read a simple command with only strings", function() { @@ -11,16 +11,16 @@ describe("Can read", function() { it("Can turn room aliases to room references", function() { const command = "#meow:example.org"; const readItems = readCommand(command); - expect(readItems.at(0)).toBeInstanceOf(MatrixRoomReference); - const roomReference = readItems.at(0) as MatrixRoomReference; - expect(roomReference.toRoomIdOrAlias()).toBe(command); + expect(readItems.at(0)).toBeInstanceOf(MatrixRoomAlias); + const roomReference = readItems.at(0) as MatrixRoomAlias; + expect(roomReference.toRoomIDOrAlias()).toBe(command); }); it("Can turn room ids to room references", function() { const command = "!foijoiejfoij:example.org"; const readItems = readCommand(command); - expect(readItems.at(0)).toBeInstanceOf(MatrixRoomReference); - const roomReference = readItems.at(0) as MatrixRoomReference; - expect(roomReference.toRoomIdOrAlias()).toBe(command); + expect(readItems.at(0)).toBeInstanceOf(MatrixRoomID); + const roomReference = readItems.at(0) as MatrixRoomID; + expect(roomReference.toRoomIDOrAlias()).toBe(command); }); it("Can read keywords and correctly parse their designators", function() { const checkKeyword = (designator: string, keyword: string) => {