Skip to content

Commit

Permalink
make all UserAgent checks case-insensitive (#4)
Browse files Browse the repository at this point in the history
* Handle alternate case for docker and Go user-agents

Some docker instances are unable to login through Beyond. That's because the user-agent is spelled with a D instead of a d.
Examples of these user-agents include:
- Docker-Client/20.10.7 (darwin)
- Docker-Client/nerdctl-v0.12.1 (linux)

* Update to use ToLower

Co-authored-by: LeoChen <[email protected]>
  • Loading branch information
leonardochen and leonardochen authored Feb 28, 2022
1 parent 80fd52a commit f8eb7d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ func (ds *dockerServer) ModifyResponse(resp *http.Response) error {

func (ds *dockerServer) RegisterHandlers(mux *http.ServeMux) {
mux.HandleFunc(ds.host+"/", func(rw http.ResponseWriter, r *http.Request) {
ua := r.UserAgent()
ua := strings.ToLower(r.UserAgent())
ua1 := strings.HasPrefix(ua, "docker/")
ua2 := strings.HasPrefix(ua, "Go-")
ua2 := strings.HasPrefix(ua, "go-")
if !ua1 && !ua2 {
handler(rw, r)
return
Expand Down

0 comments on commit f8eb7d7

Please sign in to comment.