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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 1 addition & 12 deletions src/identifiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,7 @@ impl RoomId {
#[napi(constructor, strict)]
pub fn new(id: String) -> napi::Result<Self> {
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.
Expand All @@ -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].
Expand Down
18 changes: 6 additions & 12 deletions tests/identifiers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, () => {
Expand Down
Loading