Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
trask committed Dec 1, 2024
1 parent 910381c commit e42f033
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions lychee-lib/src/utils/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,17 @@ pub(crate) fn resolve(src: &Path, dst: &Path, base: &Option<Base>) -> Result<Opt
parent.join(relative)
}
absolute if dst.starts_with("/") => {
// Absolute local links (leading slash) require the `base_url` to
// define the document root. Silently ignore the link in case the
// `base_url` is not defined.
let Some(base) = get_base_dir(base) else {
return Ok(None);
};
let Some(dir) = dirname(&base) else {
return Err(ErrorKind::InvalidBase(
base.display().to_string(),
"The given directory cannot be a base".to_string(),
));
};
join(dir.to_path_buf(), absolute)
if let Some(base) = get_base_dir(base) {
let Some(dir) = dirname(&base) else {
return Err(ErrorKind::InvalidBase(
base.display().to_string(),
"The given directory cannot be a base".to_string(),
));
};
join(dir.to_path_buf(), absolute)
} else {
absolute.to_path_buf()
}
}
_ => return Err(ErrorKind::InvalidFile(dst.to_path_buf())),
};
Expand Down

0 comments on commit e42f033

Please sign in to comment.