This commit is contained in:
Felix Ableitner 2024-09-30 11:58:04 +02:00
parent a4b022523f
commit a0646913a9
3 changed files with 5 additions and 7 deletions

View File

@ -31,7 +31,7 @@ pub async fn markdown_rewrite_remote_post_links(
// TODO: needs cleanup
if let Some(local_url) = to_local_url(&url, &context).await {
if let Some(local_url) = to_local_url(url, context).await {
let mut local_url = local_url.to_string();
// restore title
if let Some(extra) = extra {
@ -64,11 +64,10 @@ pub(crate) async fn to_local_url(url: &str, context: &Data<LemmyContext>) -> Opt
})
.ok()
.flatten()
.map(|u| u.into())
.map(std::convert::Into::into)
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::*;

View File

@ -228,8 +228,8 @@ impl Object for ApubPost {
let url_blocklist = get_url_blocklist(context).await?;
if let Some(ref mut url) = url {
is_url_blocked(&url, &url_blocklist)?;
is_valid_url(&url)?;
is_url_blocked(url, &url_blocklist)?;
is_valid_url(url)?;
if let Some(local_url) = to_local_url(url.as_str(), context).await {
*url = local_url;
}

View File

@ -39,7 +39,7 @@ pub fn markdown_rewrite_image_links(mut src: String) -> (String, Vec<Url>) {
(src, links)
}
pub fn markdown_handle_title(src: &String, start: usize, end: usize) -> (&str, Option<&str>) {
pub fn markdown_handle_title(src: &str, start: usize, end: usize) -> (&str, Option<&str>) {
let content = src.get(start..end).unwrap_or_default();
// necessary for custom emojis which look like `![name](url "title")`
let (url, extra) = if content.contains(' ') {
@ -95,7 +95,6 @@ impl UrlAndTitle for Link {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::*;