Skip to content

Commit

Permalink
download.mxid_from_mxid_uri: just detect the sigil and work bsed on t…
Browse files Browse the repository at this point in the history
…hat..

Maybe the MatrixURI library works inconsistently in this manner?
  • Loading branch information
eras committed Jan 2, 2023
1 parent 598b006 commit 746f23f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,17 @@ impl std::fmt::Display for MatrixUriParseError {

fn mxid_from_mxid_uri(mxid: &matrix_uri::MatrixId) -> String {
// I don't understand when the sigil is or isn't there..
match mxid.id_type {
matrix_uri::IdType::RoomAlias => format!("{}{}", mxid.id_type.to_sigil(), mxid.body),
_ => mxid.body.clone(),
match mxid.body.chars().next() {
Some('!' | '%' | '$' | '+' | '#' | '@') => mxid.body.clone(),
Some(_) => match mxid.id_type {
matrix_uri::IdType::RoomAlias
| matrix_uri::IdType::RoomId
| matrix_uri::IdType::EventId => {
format!("{}{}", mxid.id_type.to_sigil(), mxid.body)
}
_ => mxid.body.clone(),
},
None => "".to_string(),
}
}

Expand Down

0 comments on commit 746f23f

Please sign in to comment.