File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ func _detectRemoteURL_LocalGit(path string) (string, error) {
7777// https://github.com/mroth/bump.git
7878// git@github.com:mroth/bump.git
7979func parseGithubRemote (remoteURL string ) (owner , repo string , ok bool ) {
80- re := regexp .MustCompile (`^(?:https://|git@)github.com[:/](.*)/(.*?)(?:\.git$|$)` )
80+ re := regexp .MustCompile (`^(?:https://|git@)github\ .com[:/](.*)/(.*?)(?:\.git$|$)` )
8181 matches := re .FindStringSubmatch (remoteURL )
8282 if len (matches ) < 3 {
8383 return
Original file line number Diff line number Diff line change @@ -31,6 +31,17 @@ func Test_parseGithubRemote(t *testing.T) {
3131 wantRepo : "bump" ,
3232 wantOk : true ,
3333 },
34+ // negative cases: near-miss hostnames should not match
35+ {
36+ name : "nearMiss_HTTPS_dotReplaced" ,
37+ remoteURL : "https://githubXcom/mroth/bump.git" ,
38+ wantOk : false ,
39+ },
40+ {
41+ name : "nearMiss_SSH_dotReplaced" ,
42+ remoteURL : "git@githubXcom:mroth/bump.git" ,
43+ wantOk : false ,
44+ },
3445 }
3546 for _ , tt := range tests {
3647 t .Run (tt .name , func (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments