Skip to content

Commit

Permalink
fix: remove old testcase and use a compatible splicing method (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
r3inbowari committed Apr 24, 2024
1 parent f728f84 commit 1234b62
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
7 changes: 2 additions & 5 deletions speedtest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"math"
"net/http"
"net/url"
"path"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -76,15 +75,13 @@ func (s *Speedtest) CustomServer(host string) (*Server, error) {
if err != nil {
return nil, err
}
if path.Base(u.Path) != "upload.php" {
return nil, errors.New("please use the full URL of the server, ending in '/upload.php'")
}
parseHost := fmt.Sprintf("%s://%s%s", u.Scheme, u.Host, "/speedtest/upload.php")
return &Server{
ID: "Custom",
Lat: "?",
Lon: "?",
Country: "?",
URL: host,
URL: parseHost,
Name: u.Host,
Host: u.Host,
Sponsor: "?",
Expand Down
6 changes: 0 additions & 6 deletions speedtest/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,6 @@ func TestCustomServer(t *testing.T) {
if got.Host != "example.com" {
t.Error("did not properly set the Host field on a custom server")
}

// Missing upload.php
_, err = CustomServer("https://example.com")
if err == nil {
t.Error("did not create a custom server without upload.php")
}
}

func TestFetchServerByID(t *testing.T) {
Expand Down

0 comments on commit 1234b62

Please sign in to comment.