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:168–178  ·  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

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