Convert an absolute filesystem path into a `file://` URL (spaces encoded).
(path: &Path)
| 167 | |
| 168 | /// Convert an absolute filesystem path into a `file://` URL (spaces encoded). |
| 169 | fn path_to_file_url(path: &Path) -> String { |
| 170 | let s = path |
| 171 | .to_string_lossy() |
| 172 | .replace('\\', "/") |
| 173 | .replace(' ', "%20"); |
| 174 | if s.starts_with('/') { |
| 175 | format!("file://{}", s) // unix: file:///Users/… |
| 176 | } else { |
| 177 | format!("file:///{}", s) // windows: file:///C:/… |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | /// Spawn the platform's default opener for a URL, detached. |
| 182 | fn open_in_browser(target: &str) -> std::io::Result<()> { |
no test coverage detected