From c370ab6feacb76a5d36a294c3f8f463996050bc8 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Mon, 18 May 2020 13:52:29 +0200 Subject: [PATCH] fix: handling of {str} or {int} in request --- router.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/router.c b/router.c index 997b41d..ad2a199 100644 --- a/router.c +++ b/router.c @@ -260,9 +260,13 @@ router_find_endpoint(const char *uri_str, size_t uri_len, struct mg_str *method_ continue; } - if(strcmp(endpoints[i].route[route_part], uri_token) == 0) + if(strcmp(endpoints[i].route[route_part], "{str}") == 0) { - endpoints[i].possible_route += 3; + endpoints[i].possible_route += 1; + + endpoints[i].args[endpoints[i].args_found].type = ENDPOINT_ARG_TYPE_STR; + endpoints[i].args[endpoints[i].args_found].value.v_str = uri_token; + ++endpoints[i].args_found; continue; } if(strcmp(endpoints[i].route[route_part], "{int}") == 0) @@ -282,13 +286,9 @@ router_find_endpoint(const char *uri_str, size_t uri_len, struct mg_str *method_ ++endpoints[i].args_found; continue; } - if(strcmp(endpoints[i].route[route_part], "{str}") == 0) + if(strcmp(endpoints[i].route[route_part], uri_token) == 0) { - endpoints[i].possible_route += 1; - - endpoints[i].args[endpoints[i].args_found].type = ENDPOINT_ARG_TYPE_STR; - endpoints[i].args[endpoints[i].args_found].value.v_str = uri_token; - ++endpoints[i].args_found; + endpoints[i].possible_route += 3; continue; } endpoints[i].possible_route = 0;