sacc

sacc (saccomys): simple gopher client.
Log | Files | Refs | LICENSE

commit 4fe03eaa05536aac1704b92c0267fb099125a3a3
parent d70616c357a135b8e251fe1974cf88f529dbc67f
Author: Julian Schweinsberg <pazz0@0xfa.de>
Date:   Sun, 28 Jan 2024 15:25:55 +0100

Show correct (gopher) URLs for menuentries pointing to HTML files.

Only the 'h'tml links providing an external URI (prefixed with "URL:")
should be printed directly.
Otherwise print the link like any other gopher link.

Example for a menu pointing to HTML files in the real world:
gopher://gopher.metafilter.com/1/MetaFilter

Diffstat:
Msacc.c | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/sacc.c b/sacc.c @@ -305,10 +305,11 @@ itemuri(Item *item, char *buf, size_t bsz) n = snprintf(buf, bsz, "tn3270://%s@%s:%s", item->selector, item->host, item->port); break; - case 'h': - n = snprintf(buf, bsz, "%s", item->selector + - (strncmp(item->selector, "URL:", 4) ? 0 : 4)); - break; + case 'h': /* fallthrough */ + if (!strncmp(item->selector, "URL:", 4)) { + n = snprintf(buf, bsz, "%s", item->selector+4); + break; + } default: n = snprintf(buf, bsz, "gopher://%s", item->host);