mirror of
https://github.com/xHyroM/zed-discord-presence.git
synced 2024-11-14 18:38:05 +01:00
fix: decode uri (#15)
* fix: decode uri closes https://github.com/xhyrom/zed-discord-presence/issues/14 * refactor: remove
This commit is contained in:
parent
917a011970
commit
0449fef97f
4 changed files with 15 additions and 4 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -133,6 +133,7 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower-lsp",
|
"tower-lsp",
|
||||||
|
"urlencoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -851,6 +852,12 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "urlencoding"
|
||||||
|
version = "2.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
version = "0.8.2"
|
version = "0.8.2"
|
||||||
|
|
|
@ -11,3 +11,4 @@ git2 = { version = "0.19.0", default-features = false }
|
||||||
serde_json = { version = "1.0.122", features = ["std"] }
|
serde_json = { version = "1.0.122", features = ["std"] }
|
||||||
lazy_static = "1.5.0"
|
lazy_static = "1.5.0"
|
||||||
regex = { version = "1.10.6", default-features = false, features = ["std", "perf", "unicode-case"] }
|
regex = { version = "1.10.6", default-features = false, features = ["std", "perf", "unicode-case"] }
|
||||||
|
urlencoding = "2.1.3"
|
||||||
|
|
|
@ -62,8 +62,11 @@ impl Document {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_filename(&self) -> &str {
|
fn get_filename(&self) -> String {
|
||||||
self.path.file_name().unwrap().to_str().unwrap()
|
let filename = self.path.file_name().unwrap().to_str().unwrap();
|
||||||
|
let filename = urlencoding::decode(filename).unwrap();
|
||||||
|
|
||||||
|
filename.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_extension(&self) -> &str {
|
fn get_extension(&self) -> &str {
|
||||||
|
|
|
@ -13,7 +13,7 @@ macro_rules! replace_with_capitalization {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Placeholders<'a> {
|
pub struct Placeholders<'a> {
|
||||||
filename: &'a str,
|
filename: String,
|
||||||
workspace: &'a str,
|
workspace: &'a str,
|
||||||
language: String,
|
language: String,
|
||||||
base_icons_url: &'a str,
|
base_icons_url: &'a str,
|
||||||
|
@ -32,7 +32,7 @@ impl<'a> Placeholders<'a> {
|
||||||
pub fn replace(&self, text: &str) -> String {
|
pub fn replace(&self, text: &str) -> String {
|
||||||
replace_with_capitalization!(
|
replace_with_capitalization!(
|
||||||
text,
|
text,
|
||||||
"filename" => self.filename,
|
"filename" => self.filename.as_str(),
|
||||||
"workspace" => self.workspace,
|
"workspace" => self.workspace,
|
||||||
"language" => self.language.as_str(),
|
"language" => self.language.as_str(),
|
||||||
"base_icons_url" => self.base_icons_url
|
"base_icons_url" => self.base_icons_url
|
||||||
|
|
Loading…
Reference in a new issue