mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-27 06:41:18 +00:00
Removing pointless URL building in url blocklist regex.
This commit is contained in:
parent
0e2b3952bf
commit
7f5fcf882e
1 changed files with 2 additions and 11 deletions
|
@ -536,17 +536,8 @@ pub async fn get_url_blocklist(context: &LemmyContext) -> LemmyResult<RegexSet>
|
||||||
.try_get_with::<_, LemmyError>((), async {
|
.try_get_with::<_, LemmyError>((), async {
|
||||||
let urls = LocalSiteUrlBlocklist::get_all(&mut context.pool()).await?;
|
let urls = LocalSiteUrlBlocklist::get_all(&mut context.pool()).await?;
|
||||||
|
|
||||||
let regexes = urls.iter().map(|url| {
|
// The urls are already validated on saving, so just escape them.
|
||||||
// The scheme is removed in the saving,
|
let regexes = urls.iter().map(|url| escape(&url.url));
|
||||||
// so fake it here to build the url.
|
|
||||||
let url = &format!("https://{}", url.url);
|
|
||||||
let parsed = Url::parse(url).expect("Couldn't parse URL.");
|
|
||||||
format!(
|
|
||||||
"{}{}",
|
|
||||||
escape(parsed.host_str().expect("No domain.")),
|
|
||||||
escape(parsed.path())
|
|
||||||
)
|
|
||||||
});
|
|
||||||
|
|
||||||
let set = RegexSet::new(regexes)?;
|
let set = RegexSet::new(regexes)?;
|
||||||
Ok(set)
|
Ok(set)
|
||||||
|
|
Loading…
Reference in a new issue