Decode URL from openURLs to handle percent encoded paths

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Julia 2023-01-24 18:48:15 -05:00
parent 52296836fe
commit 0414723a54
4 changed files with 9 additions and 4 deletions

View file

@ -32,8 +32,8 @@ use settings::{
};
use simplelog::ConfigBuilder;
use smol::process::Command;
use std::fs::OpenOptions;
use std::{env, ffi::OsStr, panic, path::PathBuf, sync::Arc, thread, time::Duration};
use std::{fs::OpenOptions, os::unix::prelude::OsStrExt};
use terminal_view::{get_working_directory, TerminalView};
use fs::RealFs;
@ -90,7 +90,10 @@ fn main() {
let paths: Vec<_> = urls
.iter()
.flat_map(|url| url.strip_prefix("file://"))
.map(|path| PathBuf::from(path))
.map(|url| {
let decoded = urlencoding::decode_binary(url.as_bytes());
PathBuf::from(OsStr::from_bytes(decoded.as_ref()))
})
.collect();
open_paths_tx
.unbounded_send(paths)