Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,9 @@
"query=user=me"
]
},
"excludes": [
"uppercase-hex"
],
"expected": {
"stdout": "https://curl.se/hello?user%3dme\n",
"stderr": "",
Expand Down Expand Up @@ -2183,6 +2186,9 @@
"query:=a&b&a%26b"
]
},
"excludes": [
"uppercase-hex"
],
"expected": {
"stdout": "http://localhost/ABC%5c%5c?a&b&a%26b\n",
"returncode": 0,
Expand Down Expand Up @@ -2891,6 +2897,9 @@
"path=%61"
]
},
"excludes": [
"uppercase-hex"
],
"expected": {
"stdout": "https://example.com/one/tao/%2fB/%2561\n",
"stderr": "",
Expand Down Expand Up @@ -3536,5 +3545,18 @@
"returncode": 0,
"stderr": ""
}
},
{
"input": {
"arguments": [
"https://example.com/?ab=2&a=1&abc=3",
"--sort-query"
]
},
"expected": {
"stdout": "https://example.com/?a=1&ab=2&abc=3\n",
"returncode": 0,
"stderr": ""
}
}
]
11 changes: 5 additions & 6 deletions trurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1595,11 +1595,10 @@ static void qpair2query(CURLU *uh, struct option *o)
/* sort case insensitively */
static int cmpfunc(const void *p1, const void *p2)
{
int i;
int len = (int)((((const struct string *)p1)->len) <
(((const struct string *)p2)->len) ?
(((const struct string *)p1)->len) :
(((const struct string *)p2)->len));
size_t i;
size_t len1 = ((const struct string *)p1)->len;
size_t len2 = ((const struct string *)p2)->len;
size_t len = len1 < len2 ? len1 : len2;

for(i = 0; i < len; i++) {
char c1 = ((const struct string *)p1)->str[i] | ('a' - 'A');
Comment thread
arpitguptagithub marked this conversation as resolved.
Expand All @@ -1608,7 +1607,7 @@ static int cmpfunc(const void *p1, const void *p2)
return c1 - c2;
}

return 0;
return (len1 > len2) - (len1 < len2);
}

static bool sortquery(struct option *o)
Expand Down