Skip to content

Commit

Permalink
Merge pull request #32 from mainmatter/no-lossy-string
Browse files Browse the repository at this point in the history
  • Loading branch information
hdoordt authored Nov 6, 2024
2 parents 1aa5a8a + 4287c0e commit 59e9983
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ fn rewrite_dep_paths_as_absolute<'a, P: AsRef<std::path::Path>>(
.join(path)
.canonicalize()
.unwrap()
.to_string_lossy()
.to_str()
.expect("Canonicalized absolute path contained non-UTF-8 segments.")
.to_string()
})
}
Expand All @@ -81,9 +82,12 @@ fn rewrite_dep_paths_as_absolute<'a, P: AsRef<std::path::Path>>(
fn rewrite_dep_path_as_relative<P: AsRef<std::path::Path>>(dep: &mut Dependency, parent: P) {
if let Dependency::Detailed(detail) = dep {
detail.path = detail.path.as_mut().map(|path| {
pathdiff::diff_paths(path, parent.as_ref())
.unwrap()
.to_string_lossy()
pathdiff::diff_paths(path, parent.as_ref().canonicalize().unwrap())
.expect(
"Error rewriting dependency path as relative: unable to determine path diff.",
)
.to_str()
.expect("Error rewriting dependency path as relative: path diff is not UTF-8.")
.to_string()
})
}
Expand Down

0 comments on commit 59e9983

Please sign in to comment.