commit b86f68b083f4451754b87023d452e84da11c698c
parent d41d2b78a6334856e3c2b4f20ed8929fde93fe1d
Author: Andrew Laack <andrew@laack.co>
Date: Sun, 27 Sep 2026 20:29:48 -0500
Fix to allow inputs with ':' characters
Diffstat:
4 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/include/shared.hpp b/include/shared.hpp
@@ -2,10 +2,10 @@
#include <string>
-const std::string DEFAULT_SEARCH_ENGINE="gemini://tlgs.one/search?";
+const std::string DEFAULT_SEARCH_ENGINE = "gemini://tlgs.one/search?";
-const int SITE_CACHE_LIMIT = 10; // number of links to prefetch per page
-const int THREAD_NUM = 4; // thread count in thread pool for pre-fetching
+const int SITE_CACHE_LIMIT = 100; // number of links to prefetch per page
+const int THREAD_NUM = 10; // thread count in thread pool for pre-fetching
const int maxWidth = 80; // max text width (left and right will be padded if COLS > maxWidth)
const int CACHE_SIZE = 500; // max number of elements in history cache and prefetch cache (500 for both)
const int COLOR_LINK = 159; // color used for links
diff --git a/src/browser.cpp b/src/browser.cpp
@@ -117,7 +117,6 @@ bool Browser::goToSite(std::string url, bool addToHistory, bool refresh) {
Site* site = nullptr;
-
// Caching: when there's an identity we don't read from cache and we don't add sites to the cache
// additionally, when performing prefetch caching, we check if there's an identity for the site and if there is we
// don't send a request to it. This means prefetch caching is only used for un-authenticated hosts.
diff --git a/src/link.cpp b/src/link.cpp
@@ -60,7 +60,11 @@ Link::Link(std::string text, std::optional<uri> prior, int linkNumber) {
uri Link::parseDestination(std::string destination, std::optional<uri> prior) {
// TODO: Not sure if this is right w/ how file paths work.
- if(destination.find(":") == std::string::npos) {
+
+ // TODO: There's a mess here to untangle. Like I think there might be some relative links that'll get fucked by this.
+ // despite that, this is a requirement to get search parameters working correctly which are probably more important.
+
+ if(destination.find(":") == std::string::npos || destination[0] == '?') {
if(prior != std::nullopt) {
// query parameter special casing
if(destination.substr(0,1) == "?") {
diff --git a/tests/browser-test.cpp b/tests/browser-test.cpp
@@ -72,3 +72,12 @@ TEST_CASE("Test page downloading.") {
REQUIRE(out == b.getCurrentSite()->getBody());
REQUIRE(std::filesystem::remove(destination));
}
+
+TEST_CASE("Test encoding allows relative linking with : in parameter") {
+ Browser b{};
+ b.goToSite("gemini://tlgs.one/search");
+ REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == "gemini://tlgs.one/search");
+ b.goToSite("?https://test.com");
+ REQUIRE(b.getCurrentLink()->getLinkDestination().to_string() == "gemini://tlgs.one/search?https%3A%2F%2Ftest.com");
+}
+