The test turned a temp path into a link with `file://` + the path, which on Windows gives `file://C:\Users\...`, not a file URL, so the test failed there. It now builds `file:///C:/Users/.../my%20part.stl` on Windows (what Explorer and browsers put on the clipboard) and `file:///tmp/...` on Linux and macOS, as before. `files_in_text` already reads Windows file URLs correctly; the fixed test now checks that on Windows. Co-authored-by: Ray <raykholo@users.noreply.github.com>
This commit is contained in:
@@ -201,7 +201,11 @@ mod tests {
|
||||
std::fs::write(&spaced, b"solid").unwrap();
|
||||
let plain = d.join("brief.md");
|
||||
std::fs::write(&plain, b"x").unwrap();
|
||||
let link = |p: &Path| format!("file://{}", p.to_string_lossy().replace(' ', "%20"));
|
||||
// A proper file URL on every system: `file:///tmp/a%20b`, `file:///C:/Users/a%20b`.
|
||||
let link = |p: &Path| {
|
||||
let path = p.to_string_lossy().replace(std::path::MAIN_SEPARATOR, "/").replace(' ', "%20");
|
||||
format!("file://{}{path}", if path.starts_with('/') { "" } else { "/" })
|
||||
};
|
||||
let list = format!("# copied\n{}\r\n{}\n", link(&spaced), link(&plain));
|
||||
assert_eq!(files_in_text(&list), vec![spaced.clone(), plain.clone()]);
|
||||
assert!(matches!(decide(Some(&list), &mut Fake::default()), Paste::Files(f) if f.len() == 2));
|
||||
|
||||
Reference in New Issue
Block a user