Skip to content

Commit e9c84fb

Browse files
committed
Only match regex once.
1 parent 71cb04d commit e9c84fb

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,13 @@ async fn index(req: HttpRequest) -> Result<HttpResponse, Box<dyn Error>> {
111111
}
112112

113113
let host = res.unwrap();
114+
let domain = RE_DOMAIN.captures(host);
114115

115-
if !RE_DOMAIN.is_match(host) {
116+
if domain.is_none() {
116117
return Err("Invalid host provided".into());
117118
}
118119

119-
let domain = RE_DOMAIN.captures(host).unwrap().get(1).unwrap().as_str();
120+
let domain = domain.unwrap().get(1).unwrap().as_str();
120121

121122
let mut allowed = false;
122123

0 commit comments

Comments
 (0)