From 6f1f14a67a27b466e64cf600d86a35d2a31d7253 Mon Sep 17 00:00:00 2001 From: makeworld Date: Thu, 2 Jul 2020 11:55:41 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Cache=20pages=20with=20queries,=20d?= =?UTF-8?q?on't=20cache=20bB=20URLs=20-=20fixes=20#29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ cache/cache.go | 6 ------ display/display.go | 5 ++++- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ea692c..3a68e2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bottom bar now says `URL/Num./Search: ` when space is pressed - Update to [go-gemini](https://github.com/makeworld-the-better-one/go-gemini) v0.6.0 - Help layout doesn't have borders anymore +- Pages with query strings are still cached (#29) +- URLs or searches typed in the bottom bar are not loaded from the cache (#29) ### Fixed - Actual unicode bullet symbol is used for lists: U+2022 diff --git a/cache/cache.go b/cache/cache.go index 6710260..4bc092f 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -3,7 +3,6 @@ package cache import ( - "net/url" "strings" "sync" @@ -52,11 +51,6 @@ func Add(p *structs.Page) { // Just in case, these pages shouldn't be cached return } - // Never cache pages with query strings, to reduce unexpected behaviour - parsed, err := url.Parse(p.Url) - if err == nil && parsed.RawQuery != "" { - return - } if p.Size() > maxSize && maxSize > 0 { // This page can never be added diff --git a/display/display.go b/display/display.go index cb4b118..2b728d5 100644 --- a/display/display.go +++ b/display/display.go @@ -172,9 +172,12 @@ func Init() { // It's a full URL or search term // Detect if it's a search or URL if strings.Contains(query, " ") || (!strings.Contains(query, "//") && !strings.Contains(query, ".") && !strings.HasPrefix(query, "about:")) { - URL(viper.GetString("a-general.search") + "?" + pathEscape(query)) + u := viper.GetString("a-general.search") + "?" + pathEscape(query) + cache.Remove(u) // Don't use the cached version of the search + URL(u) } else { // Full URL + cache.Remove(query) // Don't use cached version for manually entered URL URL(query) } return