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