~sotirisp/kindleto

5bc47a2a901ca2576f6bf260eb2f050c503940ff — Sotiris Papatheodorou 1 year, 9 months ago e4ee1b6
Take index file into account when computing parent URL

This fixes not being able to go to the parent of a directory with an
index file.
1 files changed, 5 insertions(+), 1 deletions(-)

M util/url.go
M util/url.go => util/url.go +5 -1
@@ 38,7 38,11 @@ func RootURL(u url.URL) string {
// component of the supplied URL is empty or a single slash (it has no parent)
// it returns an empty string.
func ParentURL(u url.URL) string {
	u.Path = path.Dir(strings.TrimRight(u.Path, "/"))
	p := u.Path
	for _, index := range IndexNames() {
		p = strings.TrimRight(u.Path, index)
	}
	u.Path = path.Dir(strings.TrimRight(p, "/"))
	if u.Path == "." {
		return ""
	}