mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-23 12:51: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 {
|
||||
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…
Reference in a new issue