mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-14 19:26:56 -04:00
Open by a relative path finds relative links; convert reports import warnings
document.open (and file.newFromTemplate) with a path relative to the working directory took the SVG's folder from Path::parent(), which is "" for a bare file name and was then dropped, so relatively linked images were "not found" (and, linked by their bare name, not listed in missingLinks either). A relative path is now made absolute first: its folder is the working directory, as for the absolute path. vectorcraft-cli convert printed only the export's warnings; what reading the input left out now comes as importWarnings. Fixes #1604
This commit is contained in:
1 parent
eb25a85d90
commit
13bd24ba79
4 files changed
+59
-8
No files matched your search
@@ -99,3 +99,19 @@ fn info_reports_why_an_eps_read_partly() {
|
||||
assert!(w.contains("`frobnicate`"), "{v}");
|
||||
assert_eq!(v["kinds"]["Path"], 1, "{v}");
|
||||
}
|
||||
|
||||
/// #1604: convert reports what reading the input left out (here a missing linked image) as
|
||||
/// importWarnings, next to the export's own warnings.
|
||||
#[test]
|
||||
fn convert_reports_import_warnings() {
|
||||
let svg = tmp("missing-link.svg");
|
||||
std::fs::write(
|
||||
&svg,
|
||||
r#"<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40"><image width="40" height="40" href="nowhere-to-be-found.png"/></svg>"#,
|
||||
)
|
||||
.unwrap();
|
||||
let png = tmp("missing-link.png");
|
||||
let out: Value = serde_json::from_str(ok(&["convert", &svg, &png]).trim()).unwrap();
|
||||
let w = out["importWarnings"].as_array().unwrap_or_else(|| panic!("{out}"));
|
||||
assert!(w.iter().any(|w| w.as_str().unwrap().contains("nowhere-to-be-found.png")), "{out}");
|
||||
}
|
||||
Reference in new issue
Block a user