Only match regex once.

This commit is contained in:
Kavin 2022-12-02 20:20:50 +00:00
parent 71cb04d028
commit e9c84fbb7b
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD
1 changed files with 3 additions and 2 deletions

View File

@ -111,12 +111,13 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
} }
let host = res.unwrap(); let host = res.unwrap();
let domain = RE_DOMAIN.captures(host);
if !RE_DOMAIN.is_match(host) { if domain.is_none() {
return Err("Invalid host provided".into()); return Err("Invalid host provided".into());
} }
let domain = RE_DOMAIN.captures(host).unwrap().get(1).unwrap().as_str(); let domain = domain.unwrap().get(1).unwrap().as_str();
let mut allowed = false; let mut allowed = false;