File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -89,11 +89,12 @@ func FindGit(envPath string) string {
8989}
9090
9191var scpUrl = regexp .MustCompile (`^(?P<user>\S+?)@(?P<host>[a-zA-Z\d-]+(\.[a-zA-Z\d-]+)+\.?):(?P<path>.*?/.*?)$` )
92+ var allowedSchemes = []string {"git" , "ssh" }
9293
9394// Scrub rewrites arguments that look like URLs to have the HTTPS protocol.
9495func Scrub (argument string ) string {
9596 u , err := url .ParseRequestURI (argument )
96- if err == nil && u .Scheme != "" {
97+ if err == nil && u .Host != "" && contains ( allowedSchemes , u . Scheme ) {
9798 u .Scheme = "https"
9899 return u .String ()
99100 }
@@ -112,3 +113,12 @@ func Scrub(argument string) string {
112113 }
113114 return argument
114115}
116+
117+ func contains (haystack []string , needle string ) bool {
118+ for _ , hay := range haystack {
119+ if hay == needle {
120+ return true
121+ }
122+ }
123+ return false
124+ }
Original file line number Diff line number Diff line change @@ -59,6 +59,10 @@ func TestScrub(t *testing.T) {
5959 input : "ssh://github.com/dependabot/git-https-shim" ,
6060 expected : "https://github.com/dependabot/git-https-shim" ,
6161 },
62+ {
63+ input : "file://github.com/dependabot/git-https-shim" ,
64+ expected : "file://github.com/dependabot/git-https-shim" ,
65+ },
6266 {
6367 input : "HEAD~1" ,
6468 expected : "HEAD~1" ,
You can’t perform that action at this time.
0 commit comments