Skip to content

Commit

Permalink
Allow http endpoints. (#251)
Browse files Browse the repository at this point in the history
* Fixed

* removed unwanted files
  • Loading branch information
subomi authored Dec 2, 2021
1 parent 84d526f commit ad52ddc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions util/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ func CleanEndpoint(s string) (string, error) {
return "", err
}

switch u.Scheme {
case "http", "https":
default:
return "", errors.New("invalid endpoint scheme")
}

switch strings.ToLower(u.Hostname()) {
case "localhost", "127.0.0.1":
return "", errors.New("cannot use localhost or 127.0.0.1")
}

if u.Scheme != "https" {
return "", errors.New("endpoint scheme must be HTTPs only")
}

return strings.ToLower(u.String()), nil
}
2 changes: 1 addition & 1 deletion util/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestCleanEndpoint(t *testing.T) {
{"localhost:8080", true},
{"https://localhost:8080", true},
{"https://google.com", false},
{"http://google.com", true},
{"http://google.com", false},
{"https://localhost", true},
{"https://LocaLhOsT", true},
{"https://127.0.0.1", true},
Expand Down

0 comments on commit ad52ddc

Please sign in to comment.