1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-06-19 19:25:24 +00:00

🐛 Don't break visiting IPv6 hosts when port 1965 is specified

Fixes #195
This commit is contained in:
makeworld 2021-02-17 09:25:02 -05:00
parent 0e07c4789e
commit 5e889967bc
3 changed files with 12 additions and 1 deletions

View File

@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Bookmarks modal closes on ESC like the others (#173)
- Handle empty META string (#176)
- Whitespace around the URL entered in the bottom bar is stripped (#184)
- Don't break visiting IPv6 hosts when port 1965 is specified (#195)
## [1.7.2] - 2020-12-21

View File

@ -105,7 +105,12 @@ func normalizeURL(u string) string {
parsed.Fragment = "" // No fragments either
if parsed.Port() == "1965" {
// Always remove default port
parsed.Host = parsed.Hostname()
hostname := parsed.Hostname()
if strings.Contains(hostname, ":") {
parsed.Host = "[" + parsed.Hostname() + "]"
} else {
parsed.Host = parsed.Hostname()
}
}
// Add slash to the end of a URL with just a domain

View File

@ -27,6 +27,11 @@ var normalizeURLTests = []struct {
{"gemini://example.com/蛸", "gemini://example.com/%E8%9B%B8"},
{"gemini://gemini.circumlunar.space/%64%6f%63%73/;;.'%66%61%71蛸%2e%67%6d%69", "gemini://gemini.circumlunar.space/docs/%3B%3B.%27faq%E8%9B%B8.gmi"},
{"gemini://example.com/?%2Ch%64ello蛸", "gemini://example.com/?%2Chdello%E8%9B%B8"},
// IPv6 tests, see #195
{"gemini://[::1]", "gemini://[::1]/"},
{"gemini://[::1]:1965", "gemini://[::1]/"},
{"gemini://[::1]/test", "gemini://[::1]/test"},
{"gemini://[::1]:1965/test", "gemini://[::1]/test"},
}
func TestNormalizeURL(t *testing.T) {