summaryrefslogtreecommitdiff
path: root/shopify.c
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-15 08:24:10 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-15 08:24:10 +0800
commita631d884fcccdcdf826f1a6e5a4db22237b398c1 (patch)
treea3f5accd74421613c830166fd8355d9d50f8f2f5 /shopify.c
parent792ef642fa03eda4af5bc3535487faacef4fcf65 (diff)
More clarity on query building
though less efficient
Diffstat (limited to 'shopify.c')
-rw-r--r--shopify.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/shopify.c b/shopify.c
index 7efa40d..b8d6379 100644
--- a/shopify.c
+++ b/shopify.c
@@ -131,12 +131,13 @@ bool shopify_valid(struct MHD_Connection *conn, const char *url,
const char *val = (*params)[i].val;
if (strcmp(key, "hmac")) {
size_t query_len = query ? strlen(query) : 0;
- bool last = i == nparams - 1;
+ bool ampersand = i != nparams - 1;
query = realloc(query, query_len + strlen(key)
- + strlen(val) + !last + 2);
+ + strlen("=") + strlen(val) + ampersand
+ + 1);
query[query_len] = '\0';
sprintf(query, "%s%s=%s%s", query, key, val,
- last ? "" : "&");
+ ampersand ? "&" : "");
}
}
char *hmac = NULL;