Skip to content

Commit

Permalink
Improve logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh1Yo committed Jul 24, 2022
1 parent 8f3b0d9 commit 48bc3c1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
Cargo.lock
/tests
*workspace*
.vscode
2 changes: 1 addition & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ pub fn get_config() -> (Config, usize) {
let mut parameter_template = parameter_template.as_str();

if parameter_template.is_empty() {
if body_type.contains("json") && args.is_present("as-body") {
if body_type.contains("json") {
parameter_template = "\"%k\":\"%v\", ";
} else if within_headers {
parameter_template = "%k=%v; ";
Expand Down
3 changes: 3 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ pub fn make_query(config: &Config, params: &HashMap<String, String>) -> String {
query = query + &config.parameter_template.replace("%k", k).replace("%v", v);
}
query.pop();
if config.body_type.contains("json") {
query.pop(); //remove the last ','
}

if config.encode {
utf8_percent_encode(&query, &FRAGMENT).to_string()
Expand Down

0 comments on commit 48bc3c1

Please sign in to comment.