attempt to fix query params

This commit is contained in:
Richard
2026-02-04 19:29:03 +00:00
parent 7f32f34ca3
commit 4bca336048
3 changed files with 4 additions and 17 deletions

7
Cargo.lock generated
View File

@@ -1182,12 +1182,6 @@ 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 = "utf-8" name = "utf-8"
version = "0.7.6" version = "0.7.6"
@@ -1296,7 +1290,6 @@ dependencies = [
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
"url", "url",
"urlencoding",
] ]
[[package]] [[package]]

View File

@@ -11,5 +11,4 @@ tracing-subscriber = { version = "0.3", features = ["fmt"] }
clap = { version = "4", features = ["derive"] } clap = { version = "4", features = ["derive"] }
futures-util = "0.3" futures-util = "0.3"
chrono = "0.4" chrono = "0.4"
urlencoding = "2"
url = "2" url = "2"

View File

@@ -3,7 +3,7 @@ use std::path::PathBuf;
use chrono::Local; use chrono::Local;
use clap::Parser; use clap::Parser;
use url::Url; use url::{form_urlencoded, Url};
use futures_util::StreamExt; use futures_util::StreamExt;
use tokio::task::JoinSet; use tokio::task::JoinSet;
use tokio_tungstenite::{ use tokio_tungstenite::{
@@ -70,10 +70,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.map(|(k, v)| (k.into_owned(), v.into_owned())) .map(|(k, v)| (k.into_owned(), v.into_owned()))
.collect(); .collect();
let extra: Vec<(&str, &str)> = extra_params let extra: Vec<(String, String)> = form_urlencoded::parse(extra_params.as_bytes())
.split('&') .map(|(k, v)| (k.into_owned(), v.into_owned()))
.filter(|s| !s.is_empty())
.filter_map(|pair| pair.split_once('='))
.collect(); .collect();
// Rebuild query string with existing + extra params // Rebuild query string with existing + extra params
@@ -84,10 +82,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
query_pairs.append_pair(k, v); query_pairs.append_pair(k, v);
} }
for (k, v) in &extra { for (k, v) in &extra {
// Decode first since append_pair will re-encode query_pairs.append_pair(k, v);
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);
} }
} }
} }