fix: fix extension-check logic when normalizing github URLs (#158)

This commit is contained in:
Daniel Moran
2021-06-29 14:49:41 -04:00
committed by GitHub
parent 93d628dd04
commit eb99827966
3 changed files with 9 additions and 3 deletions

View File

@ -22,6 +22,12 @@ func TestNormalize(t *testing.T) {
in: url.URL{Host: "github.com", Path: "/influxdata/influxdb/blob/master/flags.yml"},
out: url.URL{Host: "raw.githubusercontent.com", Path: "/influxdata/influxdb/master/flags.yml"},
},
{
name: "github URL with extensions",
in: url.URL{Host: "github.com", Path: "/influxdata/community-templates/blob/master/github/github.yml"},
exts: []string{".yaml", ".yml", ".jsonnet", ".json"},
out: url.URL{Host: "raw.githubusercontent.com", Path: "/influxdata/community-templates/master/github/github.yml"},
},
{
name: "other URL",
in: url.URL{Host: "google.com", Path: "/fake.yml"},
@ -30,7 +36,7 @@ func TestNormalize(t *testing.T) {
{
name: "github URL - wrong extension",
in: url.URL{Host: "github.com", Path: "/influxdata/influxdb/blob/master/flags.yml"},
exts: []string{"json"},
exts: []string{".json"},
out: url.URL{Host: "github.com", Path: "/influxdata/influxdb/blob/master/flags.yml"},
},
}