Skip to content

Commit

Permalink
Modified code to use url.parse() instead of regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Himanshu Pandey committed May 30, 2019
1 parent bc0a272 commit 3dc9c34
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"fmt"
"io/ioutil"
"net"
"net/url"
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
Expand Down Expand Up @@ -361,12 +361,16 @@ func validateConfig() {

// This validates if the --registry-mirror args
// match the format of http://localhost
urlRe := regexp.MustCompile(`^http(s{0,1}):\/\/(.+?)`)
if len(registryMirror) > 0 {
for _, loc := range registryMirror {
if !urlRe.MatchString(loc) {
exit.WithCode(exit.Failure, "url provided with --registry-mirror flag is invalid %q", loc)
URL, err := url.Parse(loc)
if err != nil {
glog.Errorln("Error Parsing URL: ", err)
}
if (URL.Scheme != "http" && URL.Scheme != "https") || URL.Path != "" {
exit.Usage("Sorry, url provided with --registry-mirror flag is invalid %q", loc)
}

}
}

Expand Down

0 comments on commit 3dc9c34

Please sign in to comment.