Skip to content

Commit

Permalink
fix: PR comment, use join()
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugoch committed Feb 25, 2025
1 parent 1424fa4 commit 018545f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/api/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,13 @@ impl ApiBuilder {

fn build_headers(&self) -> HeaderMap {
let mut headers = HeaderMap::new();
let mut user_agent = "".to_string();
self.user_agent.iter().for_each(|(key, value)| {
user_agent = format!("{user_agent}; {key}/{value}");
});
headers.insert(USER_AGENT, user_agent[2..].to_string());
let user_agent = self
.user_agent
.iter()
.map(|(key, value)| format!("{key}/{value}"))
.collect::<Vec<_>>()
.join("; ");
headers.insert(USER_AGENT, user_agent.to_string());
if let Some(token) = &self.token {
headers.insert(AUTHORIZATION, format!("Bearer {token}"));
}
Expand Down
12 changes: 7 additions & 5 deletions src/api/tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,13 @@ impl ApiBuilder {

fn build_headers(&self) -> Result<HeaderMap, ApiError> {
let mut headers = HeaderMap::new();
let mut user_agent = "".to_string();
self.user_agent.clone().iter().for_each(|(key, value)| {
user_agent = format!("{user_agent}; {key}/{value}");
});
headers.insert(USER_AGENT, HeaderValue::from_str(&user_agent[2..])?);
let user_agent = self
.user_agent
.iter()
.map(|(key, value)| format!("{key}/{value}"))
.collect::<Vec<_>>()
.join("; ");
headers.insert(USER_AGENT, HeaderValue::from_str(&user_agent)?);
if let Some(token) = &self.token {
headers.insert(
AUTHORIZATION,
Expand Down

0 comments on commit 018545f

Please sign in to comment.