diff --git a/reflink.go b/reflink.go index f339dd4..7aadf29 100644 --- a/reflink.go +++ b/reflink.go @@ -224,10 +224,9 @@ func (l *Reflinker) linkGitHubURL(n *ast.AutoLink, src []byte) { } start = t.Segment.Stop } - label := n.Label(src) stop := start + len(label) - if start >= len(src) || stop >= len(src) { + if start >= len(src) || stop > len(src) { return } if src[start] == '<' && stop+1 < len(src) && src[stop+1] == '>' { @@ -239,8 +238,7 @@ func (l *Reflinker) linkGitHubURL(n *ast.AutoLink, src []byte) { return } - slug := m[1] - hash := m[2] + slug, hash := m[1], m[2] if len(hash) > 10 { hash = hash[:10] } diff --git a/reflink_test.go b/reflink_test.go index 253a021..2799d67 100644 --- a/reflink_test.go +++ b/reflink_test.go @@ -416,7 +416,7 @@ func TestLinkRefs(t *testing.T) { { what: "commit URL at end of text", input: "test https://github.com/foo/bar/commit/1d457ba853aa10f9a6c925a1b73d5aed38066ffe", - want: "tes [`foo/bar@1d457ba853`](https://github.com/foo/bar/commit/1d457ba853aa10f9a6c925a1b73d5aed38066ffe)", + want: "test [`foo/bar@1d457ba853`](https://github.com/foo/bar/commit/1d457ba853aa10f9a6c925a1b73d5aed38066ffe)", }, { what: "commit URL with explicit auto link",