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",
]
[[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]]

View File

@@ -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"

View File

@@ -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<dyn std::error::Error>> {
.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<dyn std::error::Error>> {
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);
}
}
}