Skip to content

Commit

Permalink
fixup simplified the code for query trimming only
Browse files Browse the repository at this point in the history
  • Loading branch information
bagder committed Sep 13, 2024
1 parent 00d3aab commit dd805b3
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions trurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,13 +652,14 @@ static int getarg(struct option *o,
*usedarg = gap;
}
else if(checkoptarg(o, "--trim", flag, arg)) {
trimadd(o, arg);
if(casecompare(arg, "query=", 6))
errorf(o, ERROR_TRIM, "Unsupported trim component: %s", arg);

trimadd(o, &arg[6]);
*usedarg = gap;
}
else if(checkoptarg(o, "--qtrim", flag, arg)) {
char buffer[256];
curl_msnprintf(buffer, sizeof(buffer), "query=%s", arg);
trimadd(o, buffer);
trimadd(o, arg);
*usedarg = gap;
}
else if(checkoptarg(o, "-g", flag, arg) ||
Expand Down Expand Up @@ -1240,21 +1241,15 @@ static bool trim(struct option *o)
bool query_is_modified = false;
struct curl_slist *node;
for(node = o->trim_list; node; node = node->next) {
char *ptr;
char *instr = node->data;
if(strncmp(instr, "query", 5))
/* for now we can only trim query components */
errorf(o, ERROR_TRIM, "Unsupported trim component: %s", instr);
ptr = strchr(instr, '=');
if(ptr && (ptr > instr)) {
char *ptr = node->data;
if(ptr) {
/* 'ptr' should be a fixed string or a pattern ending with an
asterisk */
size_t inslen;
bool pattern = false;
int i;
char *temp = NULL;

ptr++; /* pass the = */
inslen = strlen(ptr);
if(inslen) {
pattern = ptr[inslen - 1] == '*';
Expand Down

0 comments on commit dd805b3

Please sign in to comment.