mirror of
https://github.com/kovetskiy/mark.git
synced 2026-05-02 05:12:35 +00:00
fix #114 do not crash when resolving links on directories
This commit is contained in:
@@ -70,7 +70,13 @@ func resolveLink(
|
|||||||
|
|
||||||
if len(link.filename) > 0 {
|
if len(link.filename) > 0 {
|
||||||
filepath := filepath.Join(base, link.filename)
|
filepath := filepath.Join(base, link.filename)
|
||||||
if _, err := os.Stat(filepath); err != nil {
|
|
||||||
|
stat, err := os.Stat(filepath)
|
||||||
|
if err != nil {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if stat.IsDir() {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +161,10 @@ func parseLinks(markdown string) []markdownLink {
|
|||||||
|
|
||||||
// getConfluenceLink build (to be) link for Conflunce, and tries to verify from
|
// getConfluenceLink build (to be) link for Conflunce, and tries to verify from
|
||||||
// API if there's real link available
|
// API if there's real link available
|
||||||
func getConfluenceLink(api *confluence.API, space, title string) (string, error) {
|
func getConfluenceLink(
|
||||||
|
api *confluence.API,
|
||||||
|
space, title string,
|
||||||
|
) (string, error) {
|
||||||
link := fmt.Sprintf(
|
link := fmt.Sprintf(
|
||||||
"%s/display/%s/%s",
|
"%s/display/%s/%s",
|
||||||
api.BaseURL,
|
api.BaseURL,
|
||||||
|
|||||||
Reference in New Issue
Block a user