From ef0675fc0bcfdfaf3ea67253ab387e158ac39d45 Mon Sep 17 00:00:00 2001 From: Chloe Kudryavtsev Date: Tue, 18 Aug 2020 17:32:53 -0400 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20Allow=20relative=20URLs=20in=20?= =?UTF-8?q?bottom=20bar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- display/display.go | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/display/display.go b/display/display.go index d48220a..c44be84 100644 --- a/display/display.go +++ b/display/display.go @@ -3,7 +3,6 @@ package display import ( "fmt" "net/url" - "path" "strconv" "strings" @@ -127,27 +126,19 @@ func Init() { reset() return } - if query == ".." && tabs[tab].hasContent() { - // Go up a directory - parsed, err := url.Parse(tabs[tab].page.Url) + if query[0] == '.' && tabs[tab].hasContent() { // relative url + current, err := url.Parse(tabs[tab].page.Url) if err != nil { // This shouldn't occur return } - if parsed.Path == "/" { - // Can't go up further + target, err := current.Parse(query) + if err != nil { + // invalid relative url reset() return } - - // Ex: /test/foo/ -> /test/foo//.. -> /test -> /test/ - parsed.Path = path.Clean(parsed.Path+"/..") + "/" - if parsed.Path == "//" { - // Fix double slash that occurs at domain root - parsed.Path = "/" - } - parsed.RawQuery = "" // Remove query - URL(parsed.String()) + URL(target.String()) return } From f22ee7d76ce62ad3b02df90b8415bc9c5b4fabcf Mon Sep 17 00:00:00 2001 From: makeworld Date: Tue, 18 Aug 2020 19:48:10 -0400 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8E=A8=20Fix=20comment=20style=20and?= =?UTF-8?q?=20remove=20reset()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- display/display.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/display/display.go b/display/display.go index c44be84..58cada1 100644 --- a/display/display.go +++ b/display/display.go @@ -126,7 +126,8 @@ func Init() { reset() return } - if query[0] == '.' && tabs[tab].hasContent() { // relative url + if query[0] == '.' && tabs[tab].hasContent() { + // Relative url current, err := url.Parse(tabs[tab].page.Url) if err != nil { // This shouldn't occur @@ -134,8 +135,7 @@ func Init() { } target, err := current.Parse(query) if err != nil { - // invalid relative url - reset() + // Invalid relative url return } URL(target.String())