use the same path logic for gophers:// as gopher:// - hurl - Gopher/HTTP/HTTPS file grabber
 (HTM) git clone git://git.codemadness.org/hurl
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 795503097fd443e2cf68b26a734884ff4ed4ea1b
 (DIR) parent e3912666fc4f1516b588d03f6ae389dbc84339b4
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Sun, 28 Mar 2021 13:55:27 +0200
       
       use the same path logic for gophers:// as gopher://
       
       A type is optional.
       
       Write path logic in a bit more clear way.
       
       Diffstat:
         M hurl.c                              |      25 +++++++++++++++++--------
       
       1 file changed, 17 insertions(+), 8 deletions(-)
       ---
 (DIR) diff --git a/hurl.c b/hurl.c
       @@ -496,8 +496,12 @@ gopher_request(void)
                /* create and send path, skip type part, empty path is allowed,
                   see RFC 4266 The gopher URI Scheme - section 2.1 */
                path = u.path;
       -        if (*path == '/' && *path++)
       +        if (*path == '/') {
                        path++;
       +                if (*path)
       +                        path++; /* skip type */
       +        }
       +
                r = snprintf(buf, sizeof(buf), "%s%s%s\r\n",
                        path, u.query[0] ? "?" : "", u.query);
                if (r < 0 || (size_t)r >= sizeof(buf)) {
       @@ -547,7 +551,7 @@ gophers_request(void)
        {
                struct tls *t;
                char buf[READ_BUF_SIZ], *p;
       -        const char *errstr;
       +        const char *errstr, *path;
                size_t len = 0;
                ssize_t r;
                int fd = -1, ret = 1;
       @@ -578,8 +582,17 @@ gophers_request(void)
                if (pledge("stdio", NULL) == -1)
                        err(1, "pledge");
        
       -        /* create and send path, skip type part */
       -        r = snprintf(buf, sizeof(buf), "%s\r\n", u.path + 2);
       +        /* create and send path, skip type part, empty path is allowed,
       +           see RFC 4266 The gopher URI Scheme - section 2.1 */
       +        path = u.path;
       +        if (*path == '/') {
       +                path++;
       +                if (*path)
       +                        path++; /* skip type */
       +        }
       +
       +        r = snprintf(buf, sizeof(buf), "%s%s%s\r\n",
       +                path, u.query[0] ? "?" : "", u.query);
                if (r < 0 || (size_t)r >= sizeof(buf)) {
                        fprintf(stderr, "not writing header because it is truncated");
                        goto err;
       @@ -727,10 +740,6 @@ main(int argc, char **argv)
                        }
                        if (!u.port[0])
                                memcpy(u.port, "70", 3);
       -
       -                if (u.path[0] != '/' || u.path[1] == '\0')
       -                        errx(1, "must specify type");
       -
                        statuscode = gophers_request();
                } else {
                        if (u.proto[0])