Parse Matrix media URL for clients
This commit is contained in:
10
src/utils/matrix_utils.rs
Normal file
10
src/utils/matrix_utils.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
use ruma::OwnedServerName;
|
||||
use std::str::FromStr;
|
||||
|
||||
/// Parse Matrix media URL returning media id and server name
|
||||
pub fn parse_mxc_url(url: &str) -> Option<(&str, OwnedServerName)> {
|
||||
let strip = url.strip_prefix("mxc://")?;
|
||||
let parts = strip.split_once('/')?;
|
||||
|
||||
Some((parts.0, OwnedServerName::from_str(parts.1).ok()?))
|
||||
}
|
||||
Reference in New Issue
Block a user