Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overwrite default_args with costome_args #198

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/counter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"runtime"
"sync"

"github.com/zserge/lorca"
"github.com/lishimeng/lorca"
)

//go:embed www
Expand Down
2 changes: 1 addition & 1 deletion examples/hello/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"
"net/url"

"github.com/zserge/lorca"
"github.com/lishimeng/lorca"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/stopwatch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync/atomic"
"time"

"github.com/zserge/lorca"
"github.com/lishimeng/lorca"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/zserge/lorca
module github.com/lishimeng/lorca

go 1.16

Expand Down
13 changes: 13 additions & 0 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ func New(url, dir string, width, height int, customArgs ...string) (UI, error) {
args = append(args, customArgs...)
args = append(args, "--remote-debugging-port=0")

args = handleArgs(args)

chrome, err := newChromeWithArgs(ChromeExecutable(), args...)
done := make(chan struct{})
if err != nil {
Expand All @@ -92,6 +94,17 @@ func New(url, dir string, width, height int, customArgs ...string) (UI, error) {
return &ui{chrome: chrome, done: done, tmpDir: tmpDir}, nil
}

func handleArgs(src []string) (dest []string) {
m := make(map[string]bool)
for _, s := range src {
m[s] = true
}
for s, _ := range m {
dest = append(dest, s)
}
return
}

func (u *ui) Done() <-chan struct{} {
return u.done
}
Expand Down