1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-09-27 23:05:55 -04:00

🐛 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 ### Added
- Ability to set custom keybindings in config (#135) - 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 ## [1.7.2] - 2020-12-21
### Fixed ### Fixed

View File

@ -206,11 +206,13 @@ func Init(version, commit, builtBy string) {
// Then it's a search // Then it's a search
u := viper.GetString("a-general.search") + "?" + gemini.QueryEscape(query) 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) URL(u)
} else { } else {
// Full URL // 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) URL(query)
} }
return return
@ -572,11 +574,7 @@ func URL(u string) {
return return
} }
if !strings.HasPrefix(u, "//") && !strings.HasPrefix(u, "gemini://") && !strings.Contains(u, "://") { go goURL(t, fixUserURL(u))
// Assume it's a Gemini URL
u = "gemini://" + u
}
go goURL(t, u)
} }
func NumTabs() int { func NumTabs() int {

View File

@ -127,3 +127,17 @@ func normalizeURL(u string) string {
return parsed.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
}