🐛 Don't use cache when URL is typed in bottom bar

Fixes #159
This commit is contained in:
makeworld 2020-12-24 16:25:39 -05:00
parent 405087d3d0
commit 035fca1208
3 changed files with 21 additions and 7 deletions

View File

@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Ability to set custom keybindings in config (#135)
### Fixed
- Don't use cache when URL is typed in bottom bar (#159)
## [1.7.2] - 2020-12-21
### Fixed

View File

@ -206,11 +206,13 @@ func Init(version, commit, builtBy string) {
// Then it's a search
u := viper.GetString("a-general.search") + "?" + gemini.QueryEscape(query)
cache.RemovePage(u) // Don't use the cached version of the search
// Don't use the cached version of the search
cache.RemovePage(normalizeURL(u))
URL(u)
} else {
// Full URL
cache.RemovePage(query) // Don't use cached version for manually entered URL
// Don't use cached version for manually entered URL
cache.RemovePage(normalizeURL(fixUserURL(query)))
URL(query)
}
return
@ -572,11 +574,7 @@ func URL(u string) {
return
}
if !strings.HasPrefix(u, "//") && !strings.HasPrefix(u, "gemini://") && !strings.Contains(u, "://") {
// Assume it's a Gemini URL
u = "gemini://" + u
}
go goURL(t, u)
go goURL(t, fixUserURL(u))
}
func NumTabs() int {

View File

@ -127,3 +127,17 @@ func normalizeURL(u string) string {
return parsed.String()
}
// fixUserURL will take a user-typed URL and add a gemini scheme to it if
// necessary. It is not the same as normalizeURL, and that func should still
// be used, afterward.
//
// For example "example.com" will become "gemini://example.com", but
// "//example.com" will be left untouched.
func fixUserURL(u string) string {
if !strings.HasPrefix(u, "//") && !strings.HasPrefix(u, "gemini://") && !strings.Contains(u, "://") {
// Assume it's a Gemini URL
u = "gemini://" + u
}
return u
}