Skip to content

Commit 91eba25

Browse files
committed
remove any file extension instead of markdown
1 parent a61492b commit 91eba25

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/giturl/giturl.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package giturl
22

33
import (
44
"net/url"
5+
"path/filepath"
56
"regexp"
67
"strconv"
78
"strings"
@@ -163,15 +164,15 @@ func GenerateLink(repo, commit, file string, line int64) string {
163164
// GitHub Wiki links are formatted differently
164165
baseLink = repo[:len(repo)-9] + "/wiki/"
165166
if file != "" {
166-
baseLink += strings.TrimSuffix(file, ".md") + "/"
167+
// remove file extension
168+
baseLink += strings.TrimSuffix(file, filepath.Ext(file)) + "/"
167169
}
168170
if commit != "" {
169171
baseLink += commit
170172
}
171173
if line > 0 {
172174
baseLink += "#L" + strconv.FormatInt(line, 10)
173175
}
174-
175176
} else if file == "" {
176177
baseLink = repo[:len(repo)-4] + "/commit/" + commit
177178
} else {

0 commit comments

Comments
 (0)