diff --git a/CHANGELOG.md b/CHANGELOG.md index 6af3629..2667b7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - Update matrix-rust-sdk dependency to 0.9.0. - Minimum supported glibc version is now `2.35` (Ubuntu 22.04+ compatible). Support has been dropped for prior versions. +- `RoomId` no longer has a `serverName` property, and is allowed to not have a server name component. + This is a breaking change. ## 0.3.0-beta.1 - 2024-11-18 diff --git a/src/identifiers.rs b/src/identifiers.rs index 9da69e8..65f6f3e 100644 --- a/src/identifiers.rs +++ b/src/identifiers.rs @@ -210,12 +210,7 @@ impl RoomId { #[napi(constructor, strict)] pub fn new(id: String) -> napi::Result { let room_id = ruma::RoomId::parse(id).map_err(into_err)?; - match room_id.server_name() { - Some(_) => Ok(Self::from(room_id)), - None => Err(napi::Error::from_reason( - "Room ID does not have a valid server_name".to_owned(), - )), - } + Ok(Self::from(room_id)) } /// Return the room ID as a string. @@ -224,12 +219,6 @@ impl RoomId { pub fn to_string(&self) -> String { self.inner.as_str().to_owned() } - - /// Returns the server name of the room ID. - #[napi(getter)] - pub fn server_name(&self) -> ServerName { - ServerName { inner: self.inner.server_name().unwrap().to_owned() } - } } /// A Matrix-spec compliant [server name]. diff --git a/tests/identifiers.test.js b/tests/identifiers.test.js index 831ce4a..78e17f3 100644 --- a/tests/identifiers.test.js +++ b/tests/identifiers.test.js @@ -87,21 +87,15 @@ describe("DeviceKeyAlgorithmName", () => { }); describe(RoomId.name, () => { - test("cannot be invalid", () => { - expect(() => { - new RoomId("!foo"); - }).toThrow(); - }); - - const room = new RoomId("!foo:bar.org"); - - test("server name is present", () => { - expect(room.serverName).toBeInstanceOf(ServerName); - }); - test("can read the room ID as string", () => { + const room = new RoomId("!foo:bar.org"); expect(room.toString()).toStrictEqual("!foo:bar.org"); }); + + test("can read a room v12 ID as string", () => { + const roomV12 = new RoomId("!foo"); + expect(roomV12.toString()).toStrictEqual("!foo"); + }); }); describe(ServerName.name, () => {