Convert an absolute filesystem path into a `file://` URL (spaces encoded).
(path: &Path)
| 214 | |
| 215 | /// Convert an absolute filesystem path into a `file://` URL (spaces encoded). |
| 216 | fn path_to_file_url(path: &Path) -> String { |
| 217 | let s = path |
| 218 | .to_string_lossy() |
| 219 | .replace('\\', "/") |
| 220 | .replace(' ', "%20"); |
| 221 | if s.starts_with('/') { |
| 222 | format!("file://{}", s) // unix: file:///Users/… |
| 223 | } else { |
| 224 | format!("file:///{}", s) // windows: file:///C:/… |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | /// Spawn the platform's default opener for a URL, detached. |
| 229 | fn open_in_browser(target: &str) -> std::io::Result<()> { |
no test coverage detected