Skip to content

Commit

Permalink
support host/domain name in the original url
Browse files Browse the repository at this point in the history
  • Loading branch information
ZekeLu committed May 14, 2021
1 parent 824741b commit d84f7af
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions allocate_test.go
Expand Up @@ -5,8 +5,10 @@ import (
"context"
"fmt"
"io/ioutil"
"net"
"net/http"
"net/http/httptest"
"net/url"
"os"
"os/exec"
"strings"
Expand Down Expand Up @@ -142,6 +144,26 @@ func TestRemoteAllocator(t *testing.T) {
return "http" + wsURL[2:strings.Index(wsURL, "devtools")]
},
},
{
name: "hostname",
modifyURL: func(wsURL string) string {
h, err := os.Hostname()
if err != nil {
t.Fatal(err)
}
u, err := url.Parse(wsURL)
if err != nil {
t.Fatal(err)
}
_, post, err := net.SplitHostPort(u.Host)
if err != nil {
t.Fatal(err)
}
u.Host = net.JoinHostPort(h, post)
u.Path = "/"
return u.String()
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion util.go
Expand Up @@ -55,7 +55,7 @@ func detectURL(urlstr string) string {
u.Path = "/json/version"

// to get "webSocketDebuggerUrl" in the response
resp, err := http.Get(u.String())
resp, err := http.Get(forceIP(u.String()))
if err != nil {
return urlstr
}
Expand Down

0 comments on commit d84f7af

Please sign in to comment.