@@ -0,0 +1,37 @@ // Package github defines a router for targeting GitHub subjects. package github import ( "context" "fmt" ) // Router provides HTML URLs of GitHub subjects. type Router interface { // IssueURL returns the HTML URL of the specified GitHub issue. IssueURL(ctx context.Context, owner, repo string, issueID, commentID uint64) string // PullRequestURL returns the HTML URL of the specified GitHub pull request. PullRequestURL(ctx context.Context, owner, repo string, prID, commentID uint64) string } // DotCom provides HTML URLs of GitHub subjects on github.com. type DotCom struct{} // IssueURL returns the HTML URL of the specified GitHub issue on github.com. func (DotCom) IssueURL(_ context.Context, owner, repo string, issueID, commentID uint64) string { var fragment string if commentID != 0 { fragment = fmt.Sprintf("#issuecomment-%d", commentID) } return fmt.Sprintf("https://github.com/%s/%s/issues/%d%s", owner, repo, issueID, fragment) } // PullRequestURL returns the HTML URL of the specified GitHub pull request on github.com. func (DotCom) PullRequestURL(_ context.Context, owner, repo string, prID, commentID uint64) string { var fragment string if commentID != 0 { fragment = fmt.Sprintf("#issuecomment-%d", commentID) } return fmt.Sprintf("https://github.com/%s/%s/pull/%d%s", owner, repo, prID, fragment) }