Skip to content

Commit 78641bb

Browse files
committed
refactor(post): document COMMENT_SEARCH_CAPTURE capture invariant with .expect()
1 parent 301cd04 commit 78641bb

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/post.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ pub async fn item(req: Request<Body>) -> Result<Response<Body>, String> {
7373
}
7474

7575
let query_body = match COMMENT_SEARCH_CAPTURE.captures(&url) {
76-
Some(captures) => captures.get(1).unwrap().as_str().replace("%20", " ").replace('+', " "),
76+
Some(captures) => captures
77+
.get(1)
78+
.expect("COMMENT_SEARCH_CAPTURE has exactly one capture group; .get(1) is always Some on a match")
79+
.as_str()
80+
.replace("%20", " ")
81+
.replace('+', " "),
7782
None => String::new(),
7883
};
7984

0 commit comments

Comments
 (0)