Skip to content

Commit c531c00

Browse files
committed
graph: Simplify resolve_path by removing redundant path.is_absolute() check
1 parent f4c7254 commit c531c00

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

graph/src/components/link_resolver/file.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@ impl FileLinkResolver {
3939
fn resolve_path(&self, link: &str) -> PathBuf {
4040
let path = Path::new(link);
4141

42-
// If the path is already absolute or if we don't have a base_dir, return it as is
43-
if path.is_absolute() || self.base_dir.is_none() {
44-
path.to_owned()
45-
} else {
46-
// Otherwise, join with base_dir
47-
self.base_dir.as_ref().unwrap().join(link)
48-
}
42+
// Return the path as is if base_dir is None, or join with base_dir if present.
43+
// if "link" is an absolute path, join will simply return that path.
44+
self.base_dir
45+
.as_ref()
46+
.map_or_else(|| path.to_owned(), |base_dir| base_dir.join(link))
4947
}
5048
}
5149

0 commit comments

Comments
 (0)