diff --git a/TODO b/TODO new file mode 100644 index 0000000..658a1ae --- /dev/null +++ b/TODO @@ -0,0 +1 @@ +edit page diff --git a/server/path.go b/server/path.go index b0e877d..642718f 100644 --- a/server/path.go +++ b/server/path.go @@ -25,13 +25,19 @@ func NewPathFromLocal(p string) Path { } func NewPathFromURL(p string) Path { + p = path.Clean(p) base := path.Base(p) href := p - local := strings.TrimPrefix(p, "/notes") - if len(local) != len(p) { - local = strings.TrimPrefix(local, "/") + local := strings.TrimPrefix(p, "/") + locals := strings.SplitN(local, "/", 2) + local = locals[0] + if len(locals) > 1 { + local = locals[1] } local = path.Join(config.Root, local) + if strings.Trim(p, "/") == base { + local = config.Root + } return Path{ Base: base, HREF: href,