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:169–179  ·  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

167
168/// Convert an absolute filesystem path into a `file://` URL (spaces encoded).
169fn 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.
182fn 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