Handle three unwraps

This commit is contained in:
spikecodes
2021-05-15 14:51:57 -07:00
parent 31bf8c802e
commit 4f09333cd7
4 changed files with 15 additions and 12 deletions

View File

@ -528,7 +528,7 @@ pub fn rewrite_urls(input_text: &str) -> String {
match Regex::new(r"https://external-preview\.redd\.it(.*)[^?]") {
Ok(re) => {
if re.is_match(&text1) {
re.replace_all(&text1, format_url(re.find(&text1).unwrap().as_str())).to_string()
re.replace_all(&text1, format_url(re.find(&text1).map(|x| x.as_str()).unwrap_or_default())).to_string()
} else {
text1
}