diff --git a/Cargo.lock b/Cargo.lock index 6272896..fcf55f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1182,12 +1182,6 @@ dependencies = [ "serde", ] -[[package]] -name = "urlencoding" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" - [[package]] name = "utf-8" version = "0.7.6" @@ -1296,7 +1290,6 @@ dependencies = [ "tracing", "tracing-subscriber", "url", - "urlencoding", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 0112038..89e0c57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,5 +11,4 @@ tracing-subscriber = { version = "0.3", features = ["fmt"] } clap = { version = "4", features = ["derive"] } futures-util = "0.3" chrono = "0.4" -urlencoding = "2" url = "2" diff --git a/src/main.rs b/src/main.rs index 36c37ae..443ed70 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use chrono::Local; use clap::Parser; -use url::Url; +use url::{form_urlencoded, Url}; use futures_util::StreamExt; use tokio::task::JoinSet; use tokio_tungstenite::{ @@ -70,10 +70,8 @@ async fn main() -> Result<(), Box> { .map(|(k, v)| (k.into_owned(), v.into_owned())) .collect(); - let extra: Vec<(&str, &str)> = extra_params - .split('&') - .filter(|s| !s.is_empty()) - .filter_map(|pair| pair.split_once('=')) + let extra: Vec<(String, String)> = form_urlencoded::parse(extra_params.as_bytes()) + .map(|(k, v)| (k.into_owned(), v.into_owned())) .collect(); // Rebuild query string with existing + extra params @@ -84,10 +82,7 @@ async fn main() -> Result<(), Box> { query_pairs.append_pair(k, v); } for (k, v) in &extra { - // Decode first since append_pair will re-encode - let k_decoded = urlencoding::decode(k).unwrap_or_else(|_| (*k).into()); - let v_decoded = urlencoding::decode(v).unwrap_or_else(|_| (*v).into()); - query_pairs.append_pair(&k_decoded, &v_decoded); + query_pairs.append_pair(k, v); } } }