Skip to content

Commit

Permalink
update failure test, add error checking for singleurl
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobmealey committed Aug 15, 2023
1 parent ad10aad commit 5485e6a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

TARGET = trurl
OBJS = trurl.o
LDLIBS = $$(curl-config --libs)
CFLAGS += $$(curl-config --cflags) -W -Wall -Wshadow -Werror -pedantic -g -std=gnu99
LDLIBS = $$(~/.curl/bin/curl-config --libs)
CFLAGS += $$(~/.curl/bin/curl-config --cflags) -W -Wall -Wshadow -Werror -pedantic -g -std=gnu99
MANUAL = trurl.1

PREFIX ?= /usr/local
Expand Down
6 changes: 3 additions & 3 deletions tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -2149,14 +2149,14 @@
"input": {
"arguments": [
"--url",
"http://xn--abcdef/",
"http://xn-----/",
"--as-idn"
]
},
"required": ["punycode2idn"],
"expected": {
"stdout": "http://xn--abcdef/\n",
"stderr": "",
"stdout": "",
"stderr": "trurl note: invalid url [Bad hostname]\n",
"returncode": 0
}
}
Expand Down
7 changes: 6 additions & 1 deletion trurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1320,10 +1320,15 @@ static void singleurl(struct option *o,
else {
/* default output is full URL */
char *nurl = NULL;
if(!geturlpart(o, 0, uh, CURLUPART_URL, &nurl)) {
int rc = geturlpart(o, 0, uh, CURLUPART_URL, &nurl);
if(!rc) {
printf("%s\n", nurl);
curl_free(nurl);
}
else {
VERIFY(o, ERROR_BADURL, "invalid url [%s]", curl_url_strerror(rc));
url_is_invalid = true;
}
}

fflush(stdout);
Expand Down

0 comments on commit 5485e6a

Please sign in to comment.