Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Zivota <loewenheim@users.noreply.github.com>
  • Loading branch information
vaind and loewenheim authored Feb 11, 2023
1 parent ad7b5ef commit 61ea71c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
11 changes: 4 additions & 7 deletions symbolic-debuginfo/src/sourcebundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1151,13 +1151,10 @@ mod tests {
.flat_map(|f| {
let path = f.abs_path_str();
session.source_by_path(&path).ok().flatten().map(|source| {
(
path,
match source {
SourceCode::Content(text) => text.into_owned(),
SourceCode::Url(_) => panic!(),
},
)
let SourceCode::Content(text) = source else {
unreachable!();
};
(path, text.into_owned())
})
})
.collect();
Expand Down
11 changes: 4 additions & 7 deletions symbolic-ppdb/src/format/sourcelinks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ impl SourceLinkMappings {
*/
let key = doc.0.to_lowercase();
let url = doc.1.as_str().ok_or_else(Self::err)?.into();
let pattern = if key.ends_with('*') {
Pattern::Prefix(key[..(key.len() - 1)].into())
let pattern = if let Some(prefix) = key.strip_suffix('*') {
Pattern::Prefix(prefix.into())
} else {
Pattern::Exact(key)
};
Expand Down Expand Up @@ -103,11 +103,8 @@ impl SourceLinkMappings {
}
}
Pattern::Prefix(value) => {
if path_lower.starts_with(value) {
let replacement = path
.get(value.len()..)
.map(|v| v.replace('\\', "/"))
.unwrap_or_default();
if let Some(rest) = path_lower.strip_prefix(value) {
let replacement = rest.replace('\\', "/");
return Some(rule.url.replace('*', &replacement));
}
}
Expand Down

0 comments on commit 61ea71c

Please sign in to comment.