From 746f23f2f15487efd3dca664fe74c17ccd3b2d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erkki=20Sepp=C3=A4l=C3=A4?= Date: Mon, 2 Jan 2023 10:04:56 +0200 Subject: [PATCH] download.mxid_from_mxid_uri: just detect the sigil and work bsed on that.. Maybe the MatrixURI library works inconsistently in this manner? --- src/download.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/download.rs b/src/download.rs index 194b1a5..63f12a6 100644 --- a/src/download.rs +++ b/src/download.rs @@ -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(), } }