diff --git a/interfacer/src/browsh/browsh.go b/interfacer/src/browsh/browsh.go index 2f18af0c..e7e1b1c8 100644 --- a/interfacer/src/browsh/browsh.go +++ b/interfacer/src/browsh/browsh.go @@ -4,7 +4,6 @@ import ( "encoding/base64" "fmt" "io/ioutil" - "net/url" "os" "os/exec" "path/filepath" @@ -189,20 +188,21 @@ func ttyEntry() { TTYStart(realScreen) } -// MainEntry decides between running Browsh as a CLI app or as an HTTP web server -func MainEntry() { - pflag.Parse() - // validURL contains array of valid user inputted links. - var validURL []string +func noFlagParse() { + // validURI contains array of valid user inputted links. + var validURI []string if pflag.NArg() != 0 { for i := 0; i < len(pflag.Args()); i++ { - u, _ := url.ParseRequestURI(pflag.Args()[i]) - if u != nil { - validURL = append(validURL, pflag.Args()[i]) - } + validURI = append(validURI, pflag.Args()[i]) } } - viper.SetDefault("validURL", validURL) + viper.SetDefault("validURI", validURI) +} + +// MainEntry decides between running Browsh as a CLI app or as an HTTP web server +func MainEntry() { + pflag.Parse() + noFlagParse() Initialise() if viper.GetBool("version") { println(browshVersion) diff --git a/interfacer/src/browsh/comms.go b/interfacer/src/browsh/comms.go index 4199eca3..0d207183 100644 --- a/interfacer/src/browsh/comms.go +++ b/interfacer/src/browsh/comms.go @@ -147,12 +147,12 @@ func webSocketServer(w http.ResponseWriter, r *http.Request) { } // For some reason, using Firefox's CLI arg `--url https://google.com` doesn't consistently // work. So we do it here instead. - validURL := viper.GetStringSlice("validURL") - if len(validURL) == 0 { + validURI := viper.GetStringSlice("validURI") + if len(validURI) == 0 { sendMessageToWebExtension("/new_tab," + viper.GetString("startup-url")) } else { - for i := 0; i < len(validURL); i++ { - sendMessageToWebExtension("/new_tab," + validURL[i]) + for i := 0; i < len(validURI); i++ { + sendMessageToWebExtension("/new_tab," + validURI[i]) } } }