extractCommentID extracts the numeric comment ID from a GitHub comment URL. Handles formats like: https://github.com/owner/repo/issues/123#issuecomment-456789 https://github.com/owner/repo/pull/123#issuecomment-456789
(url string)
| 97 | // https://github.com/owner/repo/issues/123#issuecomment-456789 |
| 98 | // https://github.com/owner/repo/pull/123#issuecomment-456789 |
| 99 | func extractCommentID(url string) string { |
| 100 | if _, after, found := strings.Cut(url, "#issuecomment-"); found { |
| 101 | return after |
| 102 | } |
| 103 | // Fallback: look for /comments/ID pattern |
| 104 | const commentsPrefix = "/comments/" |
| 105 | if idx := strings.LastIndex(url, commentsPrefix); idx >= 0 { |
| 106 | rest := url[idx+len(commentsPrefix):] |
| 107 | // Take only digits |
| 108 | end := 0 |
| 109 | for end < len(rest) && rest[end] >= '0' && rest[end] <= '9' { |
| 110 | end++ |
| 111 | } |
| 112 | if end > 0 { |
| 113 | return rest[:end] |
| 114 | } |
| 115 | } |
| 116 | return "" |
| 117 | } |
no outgoing calls