MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / path_to_file_url

Function path_to_file_url

atomic-cli/src/commands/triage/mod.rs:216–226  ·  view source on GitHub ↗

Convert an absolute filesystem path into a `file://` URL (spaces encoded).

(path: &Path)

Source from the content-addressed store, hash-verified

214
215/// Convert an absolute filesystem path into a `file://` URL (spaces encoded).
216fn 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.
229fn open_in_browser(target: &str) -> std::io::Result<()> {

Callers 1

write_and_open_htmlFunction · 0.85

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected