@@ -23,13 +23,17 @@ func (d *GitHubDetector) Detect(src, _ string) (string, bool, error) {
23
23
}
24
24
25
25
func (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 {
28
33
return "" , false , fmt .Errorf (
29
34
"GitHub URLs should be github.com/username/repo" )
30
35
}
31
-
32
- urlStr := fmt .Sprintf ("https://%s" , strings .Join (parts [:3 ], "/" ))
36
+ urlStr := fmt .Sprintf ("https://%s" , strings .Join (hostAndPathParts [:3 ], "/" ))
33
37
url , err := url .Parse (urlStr )
34
38
if err != nil {
35
39
return "" , true , fmt .Errorf ("error parsing GitHub URL: %s" , err )
@@ -39,8 +43,12 @@ func (d *GitHubDetector) detectHTTP(src string) (string, bool, error) {
39
43
url .Path += ".git"
40
44
}
41
45
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 ]
44
52
}
45
53
46
54
return "git::" + url .String (), true , nil
0 commit comments