kopia lustrzana https://github.com/browsh-org/browsh
Merge pull request #227 from farhadmak/issue-205
Resolves: non-option argument instead of --startup-urlpull/231/head
commit
6c9e4beb94
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/base64"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
@ -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)
|
||||
|
|
|
@ -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() {
|
||||
|
|
Ładowanie…
Reference in New Issue