betterer
parent
a8dcdf3765
commit
738df48ad4
|
|
@ -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,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue