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 {
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,