fix regression: crash when image are from internet
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending approval

This commit is contained in:
Mylloon 2024-03-31 20:38:30 +02:00
parent e9761dfb6f
commit 1815a39fa6
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -202,9 +202,9 @@ fn fix_local_img(path: &str, html: String) -> String {
RewriteStrSettings {
element_content_handlers: vec![element!("img", |el| {
if let Some(src) = el.get_attribute("src") {
if let Some(img_src) = Path::new(path).parent() {
let img_path = img_src.join(src);
let file = fs::read_to_string(&img_path).unwrap();
let img_src = Path::new(path).parent().unwrap();
let img_path = img_src.join(src);
if let Ok(file) = fs::read_to_string(&img_path) {
let image = general_purpose::STANDARD.encode(file);
el.set_attribute(