Skip to content

Commit

Permalink
fix repetitive code
Browse files Browse the repository at this point in the history
  • Loading branch information
lovasoa committed Mar 12, 2023
1 parent 107d5ce commit 8b8b3f3
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/google_arts_and_culture/tile_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,11 @@ fn get_name_from_gap_html(html: &str) -> String {
return result
}

let name = Regex::new(r#""name":"([^"]+)"#)
Regex::new(r#""name":"([^"]+)"#)
.unwrap()
.captures(html)
.map(|c| (c[1]).to_string());

if let Some(result) = name {
return result
}

"Google Arts and Culture Image".into()
.map(|c| (c[1]).to_string())
.unwrap_or_else(||"Google Arts and Culture Image".into())
}

impl FromStr for PageInfo {
Expand Down

0 comments on commit 8b8b3f3

Please sign in to comment.