Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug of adding category with quotes #23

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ pub struct Qbit {
state: Mutex<LoginState>,
}


impl Qbit {
/// Create a new [`QbitBuilder`] to build a [`Qbit`] instance.
pub fn builder() -> QbitBuilder {
Expand Down Expand Up @@ -516,6 +515,13 @@ impl Qbit {
.unwrap()
.into_iter()
.fold(reqwest::multipart::Form::new(), |form, (k, v)| {
// If we directly call to_string() on a Value containing a string like "hello",
// it will include the quotes: "\"hello\"".
// We need to use as_str() first to get the inner string without quotes.
let v = match v.as_str() {
Some(v_str) => v_str.to_string(),
None => v.to_string(),
};
form.text(k.to_string(), v.to_string())
}),
|mut form, torrent| {
Expand Down Expand Up @@ -1510,7 +1516,11 @@ impl Qbit {
impl Clone for Qbit {
fn clone(&self) -> Self {
let state = self.state.lock().unwrap().clone();
Self { client: self.client.clone(), endpoint: self.endpoint.clone(), state: Mutex::new(state) }
Self {
client: self.client.clone(),
endpoint: self.endpoint.clone(),
state: Mutex::new(state),
}
}
}

Expand Down Expand Up @@ -1694,5 +1704,4 @@ mod test {
.unwrap();
print!("{:#?}", list);
}

}