Skip to content

Commit

Permalink
Merge pull request #227 from farhadmak/issue-205
Browse files Browse the repository at this point in the history
Resolves: non-option argument instead of --startup-url
  • Loading branch information
tobimensch authored Oct 8, 2018
2 parents cb3b5a7 + 8b7cda0 commit 6c9e4be
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
12 changes: 12 additions & 0 deletions interfacer/src/browsh/browsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/base64"
"fmt"
"io/ioutil"
"net/url"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -191,6 +192,17 @@ func ttyEntry() {
// 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
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])
}
}
}
viper.SetDefault("validURL", validURL)
Initialise()
if viper.GetBool("version") {
println(browshVersion)
Expand Down
9 changes: 8 additions & 1 deletion interfacer/src/browsh/comms.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,14 @@ 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.
sendMessageToWebExtension("/new_tab," + viper.GetString("startup-url"))
validURL := viper.GetStringSlice("validURL")
if len(validURL) == 0 {
sendMessageToWebExtension("/new_tab," + viper.GetString("startup-url"))
} else {
for i := 0; i < len(validURL); i++ {
sendMessageToWebExtension("/new_tab," + validURL[i])
}
}
}

func sendConfigToWebExtension() {
Expand Down

0 comments on commit 6c9e4be

Please sign in to comment.