@@ -23,13 +23,17 @@ func (d *GitHubDetector) Detect(src, _ string) (string, bool, error) {
2323}
2424
2525func  (d  * GitHubDetector ) detectHTTP (src  string ) (string , bool , error ) {
26- 	parts  :=  strings .Split (src , "/" )
27- 	if  len (parts ) <  3  {
26+ 	parts  :=  strings .Split (src , "?" )
27+ 	if  len (parts ) >  2  {
28+ 		return  "" , false , fmt .Errorf ("there is more than 1 '?' in the URL" )
29+ 	}
30+ 	hostAndPath  :=  parts [0 ]
31+ 	hostAndPathParts  :=  strings .Split (hostAndPath , "/" )
32+ 	if  len (hostAndPathParts ) <  3  {
2833		return  "" , false , fmt .Errorf (
2934			"GitHub URLs should be github.com/username/repo" )
3035	}
31- 
32- 	urlStr  :=  fmt .Sprintf ("https://%s" , strings .Join (parts [:3 ], "/" ))
36+ 	urlStr  :=  fmt .Sprintf ("https://%s" , strings .Join (hostAndPathParts [:3 ], "/" ))
3337	url , err  :=  url .Parse (urlStr )
3438	if  err  !=  nil  {
3539		return  "" , true , fmt .Errorf ("error parsing GitHub URL: %s" , err )
@@ -39,8 +43,12 @@ func (d *GitHubDetector) detectHTTP(src string) (string, bool, error) {
3943		url .Path  +=  ".git" 
4044	}
4145
42- 	if  len (parts ) >  3  {
43- 		url .Path  +=  "//"  +  strings .Join (parts [3 :], "/" )
46+ 	if  len (hostAndPathParts ) >  3  {
47+ 		url .Path  +=  "//"  +  strings .Join (hostAndPathParts [3 :], "/" )
48+ 	}
49+ 
50+ 	if  len (parts ) ==  2  {
51+ 		url .RawQuery  =  parts [1 ]
4452	}
4553
4654	return  "git::"  +  url .String (), true , nil 
0 commit comments