Skip to content

Commit

Permalink
chore: fix GetRelativeIssueURL for gitlab
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Sep 20, 2018
1 parent 855c3a6 commit 23b82c1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ func (i Issue) GetRelativeIssueURL(target string) string {

//target = strings.Replace(target, "#", "issues/", -1)

if len(strings.Split(target, "/")) > 3 {
target = fmt.Sprintf("http://%s", target)
}

u, err := url.Parse(target)
if err != nil {
return ""
Expand All @@ -267,7 +271,7 @@ func (i Issue) GetRelativeIssueURL(target string) string {
path = i.Path()
}

return fmt.Sprintf("%s/%s/issues/%s", i.ProviderURL(), path, u.Fragment)
return fmt.Sprintf("%s/%s/issues/%s", strings.TrimRight(i.ProviderURL(), "/"), path, u.Fragment)
}

func (i Issue) BlocksAnEpic() bool {
Expand Down Expand Up @@ -490,7 +494,7 @@ func (i Issue) MatchesWithATarget(targets []string) bool {
return true
}
} else {
if i.URL[:len(fullTarget)] == fullTarget {
if len(fullTarget) <= len(i.URL) && i.URL[:len(fullTarget)] == fullTarget {
return true
}
}
Expand Down

0 comments on commit 23b82c1

Please sign in to comment.