diff options
| author | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-09-22 16:31:01 +0800 |
|---|---|---|
| committer | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-09-22 16:31:01 +0800 |
| commit | eab0c675a0375411ccb94d509d1437af109d1ad4 (patch) | |
| tree | dfd29ad90dbaf859bbe180296c4e76a89112dd21 /client.c | |
| parent | 33c38800f850bb673bbe1555e007a2e462e682c7 (diff) | |
Remove slash prefix, but append it if the url value is not yet
Diffstat (limited to 'client.c')
| -rw-r--r-- | client.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1,5 +1,5 @@ -#include <stdlib.h> #include <stdbool.h> +#include <stdlib.h> #include "request.h" #include "rtclient/client.h" @@ -17,8 +17,12 @@ bool rtclient_init(const char *url) #ifdef DEBUG curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); #endif - server_url = malloc(strlen(url) + 1); + size_t length = strlen(url); + bool append = !(bool)(url[length - 1] == '/'); + server_url = malloc(length + (size_t)append + 1); strcpy(server_url, url); + if (append) + strcat(server_url, "/"); } return (bool)curl; |