Removing pointless URL building in url blocklist regex.

fix_domain_unique_blocking
Dessalines 3 weeks ago
parent 0e2b3952bf
commit 7f5fcf882e

@ -536,17 +536,8 @@ pub async fn get_url_blocklist(context: &LemmyContext) -> LemmyResult<RegexSet>
.try_get_with::<_, LemmyError>((), async {
let urls = LocalSiteUrlBlocklist::get_all(&mut context.pool()).await?;
let regexes = urls.iter().map(|url| {
// The scheme is removed in the saving,
// 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())
)
});
// The urls are already validated on saving, so just escape them.
let regexes = urls.iter().map(|url| escape(&url.url));
let set = RegexSet::new(regexes)?;
Ok(set)

Loading…
Cancel
Save