fix search paths for root+

This commit is contained in:
Bel LaPointe
2019-12-17 16:14:32 -07:00
parent 4a7efd4016
commit a7df97aae5
3 changed files with 53 additions and 6 deletions

View File

@@ -20,9 +20,20 @@ func NewPathFromLocal(p string) Path {
if strings.HasPrefix(root, "./") {
root = root[2:]
}
if strings.HasSuffix(root, "/") {
root = root[:len(root)-1]
}
splits := strings.SplitN(p, root, 2)
for len(splits) > 0 && splits[0] == "" {
splits = splits[1:]
}
if len(splits) == 0 {
splits = []string{"", ""}
}
href := splits[0]
if len(splits) > 1 && (splits[0] == "" || splits[0] == "/") {
if len(splits) == 1 && (splits[0] == root || splits[0] == config.Root) {
href = ""
} else if splits[0] == "" || splits[0] == "/" {
href = splits[1]
}
href = path.Join("/notes", href)