Recently Written · git

sacc

Mirror of git://bitreich.org/sacc, the sacc gopher client from bitreich.org.

git clone https://github.com/equwal/sacc

Log | Files | Refs


commit 4fe03eaa05536aac1704b92c0267fb099125a3a3
Julian Schweinsberg <pazz0@0xfa.de>
2024-01-28 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

 sacc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/sacc.c b/sacc.c
index 5116486..c959392 100644
--- 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);