mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-10-01 01:36:12 -04:00
clippy
This commit is contained in:
parent
a4b022523f
commit
a0646913a9
@ -31,7 +31,7 @@ pub async fn markdown_rewrite_remote_post_links(
|
|||||||
|
|
||||||
// TODO: needs cleanup
|
// 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();
|
let mut local_url = local_url.to_string();
|
||||||
// restore title
|
// restore title
|
||||||
if let Some(extra) = extra {
|
if let Some(extra) = extra {
|
||||||
@ -64,11 +64,10 @@ pub(crate) async fn to_local_url(url: &str, context: &Data<LemmyContext>) -> Opt
|
|||||||
})
|
})
|
||||||
.ok()
|
.ok()
|
||||||
.flatten()
|
.flatten()
|
||||||
.map(|u| u.into())
|
.map(std::convert::Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[expect(clippy::unwrap_used)]
|
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -228,8 +228,8 @@ impl Object for ApubPost {
|
|||||||
let url_blocklist = get_url_blocklist(context).await?;
|
let url_blocklist = get_url_blocklist(context).await?;
|
||||||
|
|
||||||
if let Some(ref mut url) = url {
|
if let Some(ref mut url) = url {
|
||||||
is_url_blocked(&url, &url_blocklist)?;
|
is_url_blocked(url, &url_blocklist)?;
|
||||||
is_valid_url(&url)?;
|
is_valid_url(url)?;
|
||||||
if let Some(local_url) = to_local_url(url.as_str(), context).await {
|
if let Some(local_url) = to_local_url(url.as_str(), context).await {
|
||||||
*url = local_url;
|
*url = local_url;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ pub fn markdown_rewrite_image_links(mut src: String) -> (String, Vec<Url>) {
|
|||||||
(src, links)
|
(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();
|
let content = src.get(start..end).unwrap_or_default();
|
||||||
// necessary for custom emojis which look like `![name](url "title")`
|
// necessary for custom emojis which look like `![name](url "title")`
|
||||||
let (url, extra) = if content.contains(' ') {
|
let (url, extra) = if content.contains(' ') {
|
||||||
@ -95,7 +95,6 @@ impl UrlAndTitle for Link {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[expect(clippy::unwrap_used)]
|
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
Loading…
Reference in New Issue
Block a user