From fac0ce6503ade9fa37021b47fdc4e6563997cf4e Mon Sep 17 00:00:00 2001 From: Laan Tungir Date: Mon, 4 May 2026 08:03:17 -0400 Subject: [PATCH] v0.0.13 - Fix selector parsing to use last params element for nostr_index options --- src/dispatcher.c | 5 ++++- src/main.c | 4 ++-- src/server.c | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/dispatcher.c b/src/dispatcher.c index 1e1379e..5ba4f29 100644 --- a/src/dispatcher.c +++ b/src/dispatcher.c @@ -584,7 +584,10 @@ char *dispatcher_handle_request(dispatcher_ctx_t *ctx, const char *json_request) selector_request_init(&selector_req); - options_item = cJSON_GetArrayItem(params_item, 1); + { + int params_count = cJSON_GetArraySize(params_item); + options_item = (params_count > 0) ? cJSON_GetArrayItem(params_item, params_count - 1) : NULL; + } if (cJSON_IsObject(options_item)) { tmp = cJSON_GetObjectItemCaseSensitive(options_item, "role"); if (tmp != NULL) { diff --git a/src/main.c b/src/main.c index 120efef..fbb904f 100644 --- a/src/main.c +++ b/src/main.c @@ -451,8 +451,8 @@ int socket_name_random(char *out, size_t out_len); /* Version information (auto-updated by build/version tooling) */ #define NSIGNER_VERSION_MAJOR 0 #define NSIGNER_VERSION_MINOR 0 -#define NSIGNER_VERSION_PATCH 12 -#define NSIGNER_VERSION "v0.0.12" +#define NSIGNER_VERSION_PATCH 13 +#define NSIGNER_VERSION "v0.0.13" /* NSIGNER_HEADERLESS_DECLS_END */ diff --git a/src/server.c b/src/server.c index dc0c48a..65251dd 100644 --- a/src/server.c +++ b/src/server.c @@ -831,7 +831,10 @@ static int extract_method_and_selector(const char *json, params_item = cJSON_GetObjectItemCaseSensitive(root, "params"); if (cJSON_IsArray(params_item)) { - options_item = cJSON_GetArrayItem(params_item, 1); + { + int params_count = cJSON_GetArraySize(params_item); + options_item = (params_count > 0) ? cJSON_GetArrayItem(params_item, params_count - 1) : NULL; + } if (cJSON_IsObject(options_item)) { tmp = cJSON_GetObjectItemCaseSensitive(options_item, "role"); if (cJSON_IsString(tmp) && tmp->valuestring != NULL) {