mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-12 13:30:26 +00:00
Fix some bugs with links
This commit is contained in:
parent
d9921a8649
commit
b2e8cb1da8
13
link/link.go
13
link/link.go
@ -66,7 +66,7 @@ func (l *Link) Classes() string {
|
|||||||
func (l *Link) Href() string {
|
func (l *Link) Href() string {
|
||||||
switch l.Kind {
|
switch l.Kind {
|
||||||
case LinkExternal, LinkLocalRoot:
|
case LinkExternal, LinkLocalRoot:
|
||||||
return l.Address
|
return l.Address + l.Anchor
|
||||||
default:
|
default:
|
||||||
return "/hypha/" + l.Address + l.Anchor
|
return "/hypha/" + l.Address + l.Anchor
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ func From(address, display, hyphaName string) *Link {
|
|||||||
link.Display = strings.TrimSpace(display)
|
link.Display = strings.TrimSpace(display)
|
||||||
}
|
}
|
||||||
|
|
||||||
if pos := strings.IndexRune(address, '#'); pos != -1 {
|
if pos := strings.IndexRune(address, '#'); pos != -1 && pos != 0 {
|
||||||
link.Anchor = address[pos:]
|
link.Anchor = address[pos:]
|
||||||
address = address[:pos]
|
address = address[:pos]
|
||||||
}
|
}
|
||||||
@ -114,7 +114,12 @@ func From(address, display, hyphaName string) *Link {
|
|||||||
link.Display = link.Display[2:]
|
link.Display = link.Display[2:]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
link.Display += link.Anchor
|
||||||
link.Address = address
|
link.Address = address
|
||||||
|
case strings.HasPrefix(address, "#"):
|
||||||
|
link.Kind = LinkLocalHypha
|
||||||
|
link.Address = util.CanonicalName(hyphaName)
|
||||||
|
link.Anchor = address
|
||||||
case strings.HasPrefix(address, "/"):
|
case strings.HasPrefix(address, "/"):
|
||||||
link.Address = address
|
link.Address = address
|
||||||
link.Kind = LinkLocalRoot
|
link.Kind = LinkLocalRoot
|
||||||
@ -124,10 +129,6 @@ func From(address, display, hyphaName string) *Link {
|
|||||||
case strings.HasPrefix(address, "../"):
|
case strings.HasPrefix(address, "../"):
|
||||||
link.Kind = LinkLocalHypha
|
link.Kind = LinkLocalHypha
|
||||||
link.Address = util.CanonicalName(path.Join(path.Dir(hyphaName), address[3:]))
|
link.Address = util.CanonicalName(path.Join(path.Dir(hyphaName), address[3:]))
|
||||||
case strings.HasPrefix(address, "#"):
|
|
||||||
link.Kind = LinkLocalHypha
|
|
||||||
link.Address = util.CanonicalName(hyphaName)
|
|
||||||
link.Anchor = address
|
|
||||||
default:
|
default:
|
||||||
link.Kind = LinkLocalHypha
|
link.Kind = LinkLocalHypha
|
||||||
link.Address = util.CanonicalName(address)
|
link.Address = util.CanonicalName(address)
|
||||||
|
Loading…
Reference in New Issue
Block a user