Browse Source

toLower the servername from the client on register

main
forest 1 month ago
parent
commit
ae4d980903
2 changed files with 3 additions and 3 deletions
  1. +2
    -2
      main.go
  2. +1
    -1
      picopublish.sh

+ 2
- 2
main.go View File

@ -651,9 +651,9 @@ func (daemon *DaemonAPI) ServeHTTP(responseWriter http.ResponseWriter, request *
responseWriter.Header().Set("Content-Type", "application/json")
responseWriter.Write(statusBytes)
case "/register":
serverName := request.URL.Query().Get("serverName")
serverName := strings.ToLower(request.URL.Query().Get("serverName"))
subdomainRegex := regexp.MustCompile("^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$")
subdomainRegex := regexp.MustCompile("^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$")
if !subdomainRegex.MatchString(serverName) {
http.Error(responseWriter, "400 Bad Request, the serverName must be a valid subdomain. It should only contain letters, numbers, and dashes", http.StatusBadRequest)
return


+ 1
- 1
picopublish.sh View File

@ -30,9 +30,9 @@ function build() {
echo "https://picopublish.sequentialread.com/files/$gzip_file_name"
}
build linux amd64
build linux arm
build linux arm64
build linux amd64
build windows amd64
#build darwin arm64
build darwin amd64

Loading…
Cancel
Save