master
scratch 2019-10-19 06:16:02 +00:00
parent a8dcdf3765
commit 738df48ad4
2 changed files with 10 additions and 3 deletions

1
TODO Normal file
View File

@ -0,0 +1 @@
edit page

View File

@ -25,13 +25,19 @@ func NewPathFromLocal(p string) Path {
} }
func NewPathFromURL(p string) Path { func NewPathFromURL(p string) Path {
p = path.Clean(p)
base := path.Base(p) base := path.Base(p)
href := p href := p
local := strings.TrimPrefix(p, "/notes") local := strings.TrimPrefix(p, "/")
if len(local) != len(p) { locals := strings.SplitN(local, "/", 2)
local = strings.TrimPrefix(local, "/") local = locals[0]
if len(locals) > 1 {
local = locals[1]
} }
local = path.Join(config.Root, local) local = path.Join(config.Root, local)
if strings.Trim(p, "/") == base {
local = config.Root
}
return Path{ return Path{
Base: base, Base: base,
HREF: href, HREF: href,