mirror of
https://github.com/makeworld-the-better-one/amfora.git
synced 2024-08-16 18:20:50 +03:00
parent
2f214b547c
commit
a3713075dd
@ -152,7 +152,7 @@ func addBookmark() {
|
||||
t := tabs[curTab]
|
||||
p := t.page
|
||||
|
||||
if !t.hasContent() {
|
||||
if !t.hasContent() || t.isAnAboutPage() {
|
||||
// It's an about: page, or a malformed one
|
||||
return
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ func Init(version, commit, builtBy string) {
|
||||
reset()
|
||||
return
|
||||
}
|
||||
if query[0] == '.' && tabs[tab].hasContent() {
|
||||
if query[0] == '.' && tabs[tab].hasContent() && !tabs[tab].isAnAboutPage() {
|
||||
// Relative url
|
||||
current, err := url.Parse(tabs[tab].page.URL)
|
||||
if err != nil {
|
||||
|
@ -321,8 +321,14 @@ func downloadPage(p *structs.Page) (string, error) {
|
||||
func downloadNameFromURL(dir, u, ext string) (string, error) {
|
||||
var name string
|
||||
var err error
|
||||
|
||||
parsed, _ := url.Parse(u)
|
||||
if parsed.Path == "" || path.Base(parsed.Path) == "/" {
|
||||
if strings.HasPrefix(u, "about:") {
|
||||
name, err = getSafeDownloadName(dir, parsed.Opaque+ext, true, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
} else if parsed.Path == "" || path.Base(parsed.Path) == "/" {
|
||||
// No file, just the root domain
|
||||
name, err = getSafeDownloadName(dir, parsed.Hostname()+ext, true, 0)
|
||||
if err != nil {
|
||||
@ -340,6 +346,7 @@ func downloadNameFromURL(dir, u, ext string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
return filepath.Join(dir, name), nil
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) {
|
||||
t.mode = tabModeDone
|
||||
|
||||
go func(p *structs.Page) {
|
||||
if b && t.hasContent() && viper.GetBool("subscriptions.popup") {
|
||||
if b && t.hasContent() && !t.isAnAboutPage() && viper.GetBool("subscriptions.popup") {
|
||||
// The current page might be an untracked feed, and the user wants
|
||||
// to be notified in such cases.
|
||||
|
||||
|
@ -23,7 +23,7 @@ func followLink(t *tab, prev, next string) {
|
||||
return
|
||||
}
|
||||
|
||||
if t.hasContent() {
|
||||
if t.hasContent() && !t.isAnAboutPage() {
|
||||
nextURL, err := resolveRelLink(t, prev, next)
|
||||
if err != nil {
|
||||
Error("URL Error", err.Error())
|
||||
|
@ -304,7 +304,7 @@ func addSubscription() {
|
||||
t := tabs[curTab]
|
||||
p := t.page
|
||||
|
||||
if !t.hasContent() {
|
||||
if !t.hasContent() || t.isAnAboutPage() {
|
||||
// It's an about: page, or a malformed one
|
||||
return
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ func (t *tab) pageDown() {
|
||||
}
|
||||
|
||||
// hasContent returns false when the tab's page is malformed,
|
||||
// has no content or URL, or if it's an 'about:' page.
|
||||
// has no content or URL.
|
||||
func (t *tab) hasContent() bool {
|
||||
if t.page == nil || t.view == nil {
|
||||
return false
|
||||
@ -221,15 +221,17 @@ func (t *tab) hasContent() bool {
|
||||
if t.page.URL == "" {
|
||||
return false
|
||||
}
|
||||
if strings.HasPrefix(t.page.URL, "about:") {
|
||||
return false
|
||||
}
|
||||
if t.page.Content == "" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// isAnAboutPage returns true when the tab's page is an about page
|
||||
func (t *tab) isAnAboutPage() bool {
|
||||
return strings.HasPrefix(t.page.URL, "about:")
|
||||
}
|
||||
|
||||
// applyHorizontalScroll handles horizontal scroll logic including left margin resizing,
|
||||
// see #197 for details. Use applyScroll instead.
|
||||
//
|
||||
|
@ -90,7 +90,7 @@ func textWidth() int {
|
||||
// It also returns an error if it could not resolve the links, which should be displayed
|
||||
// to the user.
|
||||
func resolveRelLink(t *tab, prev, next string) (string, error) {
|
||||
if !t.hasContent() {
|
||||
if !t.hasContent() || t.isAnAboutPage() {
|
||||
return next, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user