foreseen

A text-based gemini browser with prefetching
git clone git://git.laack.co/foreseen.git
Log | Files | Refs | README | LICENSE

commit 52c447ab4f884422dde5f250aaf752978bed70e0
parent 979e149771fecfff157eba75349882435d50060f
Author: Andrew Laack <andrew@laack.co>
Date:   Tue, 29 Sep 2026 11:56:17 -0500

Fixed a cli input edge case

Diffstat:
MTODO.txt | 3---
Msrc/browser.cpp | 1-
Msrc/main.cpp | 1-
Msrc/utils.cpp | 2+-
Mtests/pure-test.cpp | 13+++++++++++++
5 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/TODO.txt b/TODO.txt @@ -107,9 +107,6 @@ --- - BUGS: - - just typing in: - - "what :// :// test" --- fails - - i'd expect that to be searched. - gemini://9e4.com - that site just seems to ... hang? for like a long time, too long. - back button seems to still sometimes go back to the same page I was on before diff --git a/src/browser.cpp b/src/browser.cpp @@ -15,7 +15,6 @@ #include <vector> -// TODO: Wrap this because it could probably throw. std::string Browser::tryDownloadPage(std::string downloadPath) noexcept { std::string body = currentSite->getBody(); Link* current = getCurrentLink(); diff --git a/src/main.cpp b/src/main.cpp @@ -2,7 +2,6 @@ #include "../include/utils.hpp" #include <algorithm> #include <cassert> -#include <cctype> #include <chrono> #include <csignal> #include <cstdint> diff --git a/src/utils.cpp b/src/utils.cpp @@ -388,7 +388,7 @@ Destination handleDestinationResolution(std::string destination, bool isCli) { throw std::invalid_argument("Unable to convert fully"); } } catch (...) { - if(destination.find(":") == std::string::npos) { + if(destination.find(":") == std::string::npos || destination.find(' ') != std::string::npos) { if(destination.find('.') != std::string::npos && destination.find(' ') == std::string::npos) { destination = "gemini://" + destination; } else { diff --git a/tests/pure-test.cpp b/tests/pure-test.cpp @@ -61,6 +61,19 @@ TEST_CASE("Verify urls with numeric prefix are resolved correctly") { REQUIRE(handleDestinationResolution("123movies.com",false).destination == "gemini://123movies.com"); } +TEST_CASE("Inputs with spaces outside of the cli are always searched") { + auto d1 = handleDestinationResolution("what :// :// test", false); + REQUIRE(d1.destination == "gemini://tlgs.one/search?what%20%3A%2F%2F%20%3A%2F%2F%20test"); + rc::check("Inputs with spaces outside of the cli are always searched", + [](const std::string& st) { + auto dest = handleDestinationResolution(st, false); + if(st.find(' ') != std::string::npos) { + RC_ASSERT(dest.destination.find("tlgs.one") != std::string::npos); + } + }); +} + + TEST_CASE("Test user input handling for destinations") { SECTION("Convert numbers to link numbers") {