Skip to content

Commit 1d4de73

Browse files
Use file:// protocol on non-Windows platforms (#22)
1 parent 5c675dc commit 1d4de73

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src-tauri/src/util.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,14 @@ pub(crate) fn is_dir_empty(dir: &PathBuf) -> Result<bool> {
162162
}
163163

164164
pub(crate) fn get_path_as_file_uri(path: &Path) -> String {
165-
let uri = format!("file:///{}", path.to_string_lossy());
165+
let protocol = if cfg!(target_os = "windows") {
166+
"file:///"
167+
} else {
168+
"file://"
169+
};
170+
171+
let mut uri = String::from(protocol);
172+
uri.push_str(&path.to_string_lossy());
166173
uri.replace("\\", "/")
167174
}
168175

0 commit comments

Comments
 (0)