Skip to content

Commit

Permalink
Dont panic if invalid desc
Browse files Browse the repository at this point in the history
  • Loading branch information
pawurb committed Oct 25, 2024
1 parent 9fdae7e commit ade8020
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,14 @@ async fn execute() -> Result<(), PgExtrasError> {
}

fn extract_desc(desc: &str) -> String {
let start = desc.find("/*").unwrap();
let end = desc.find("*/").unwrap();
let extracted = &desc[start + 2..end];
let mut trimmed = extracted.trim().to_string();
if trimmed.ends_with('.') {
trimmed.pop();
if let (Some(start), Some(end)) = (desc.find("/*"), desc.find("*/")) {
let extracted = &desc[start + 2..end];
let mut trimmed = extracted.trim().to_string();
if trimmed.ends_with('.') {
trimmed.pop();
}
trimmed
} else {
desc.to_string()
}
trimmed
}

0 comments on commit ade8020

Please sign in to comment.