-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
identifiers: Don't require room IDs to contain a server name
Room IDs being splittable into localpart and servername does not have much inherent value and there are proposals like MSC4051¹ that propose changing the format. Relaxing the rules makes Ruma forwards-compatible with those proposals. The server_name accessor is kept because it is used by at least one downstream, but is updated to return an `Option`. ¹ matrix-org/matrix-spec-proposals#4051
- Loading branch information
Showing
2 changed files
with
15 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
use crate::{validate_delimited_id, Error}; | ||
use crate::{server_name, validate_id, Error}; | ||
|
||
pub fn validate(s: &str) -> Result<(), Error> { | ||
validate_delimited_id(s, &['!']) | ||
validate_id(s, &['!'])?; | ||
if let Some(colon_idx) = s.find(':') { | ||
server_name::validate(&s[colon_idx + 1..])?; | ||
} | ||
|
||
Ok(()) | ||
} |