From ee0a6e23e7ab79b44ebc996bd7cf129c59e52718 Mon Sep 17 00:00:00 2001 From: Egor Kovetskiy Date: Sat, 11 Sep 2021 14:37:45 +0300 Subject: [PATCH] fix #114 do not crash when resolving links on directories --- pkg/mark/link.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/mark/link.go b/pkg/mark/link.go index 57f4409..2caf9aa 100644 --- a/pkg/mark/link.go +++ b/pkg/mark/link.go @@ -70,7 +70,13 @@ func resolveLink( if len(link.filename) > 0 { 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 } @@ -155,7 +161,10 @@ func parseLinks(markdown string) []markdownLink { // getConfluenceLink build (to be) link for Conflunce, and tries to verify from // 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( "%s/display/%s/%s", api.BaseURL,