From 2f233906962ddd67d48ec5b63e6c3f0b118aec96 Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Mon, 8 Feb 2021 02:52:53 +0000 Subject: [PATCH] search: trim trailing whitespace (#184) When amfora is given a string to search, if that string contains a valid protocol (gemini://), and that string contains trailing whitespace, then the string is treated as a search term. Although perhaps slightly more uncommon, if the input string was as a result of copy/paste then it's possible the string could contain trailing spaces, which is not what was intended, but rather should be removed so that it's treated either as a valid gemini:// link or a search term. Some efforts around this appeared in #138 --- display/display.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/display/display.go b/display/display.go index e6a2a5d..d07cac4 100644 --- a/display/display.go +++ b/display/display.go @@ -198,6 +198,11 @@ func Init(version, commit, builtBy string) { } else { // It's a full URL or search term // Detect if it's a search or URL + + // Remove whitespace from the string. + // We don't want to convert legitimate + // :// links to search terms. + query := strings.TrimSpace(query) if (strings.Contains(query, " ") && !hasSpaceisURL.MatchString(query)) || (!strings.HasPrefix(query, "//") && !strings.Contains(query, "://") && !strings.Contains(query, ".")) && !strings.HasPrefix(query, "about:") {