Address PR comments
This commit is contained in:
parent
dd1c24a20a
commit
7551139caf
2 changed files with 6 additions and 10 deletions
|
|
@ -30,10 +30,10 @@ func ForOS(goos, url string) *exec.Cmd {
|
|||
r := strings.NewReplacer("&", "^&")
|
||||
args = append(args, "/c", "start", r.Replace(url))
|
||||
default:
|
||||
if findExe("xdg-open") {
|
||||
exe = "xdg-open"
|
||||
} else {
|
||||
if findExe("wslview") {
|
||||
exe = "wslview"
|
||||
} else {
|
||||
exe = "xdg-open"
|
||||
}
|
||||
args = append(args, url)
|
||||
}
|
||||
|
|
@ -58,9 +58,5 @@ func FromLauncher(launcher, url string) (*exec.Cmd, error) {
|
|||
|
||||
var findExe = func(command string) bool {
|
||||
_, err := exec.LookPath(command)
|
||||
if err != nil {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
return err == nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ func TestForOS(t *testing.T) {
|
|||
goos: "linux",
|
||||
url: "https://example.com/path?a=1&b=2",
|
||||
},
|
||||
findExe: true,
|
||||
findExe: false, // wslview does not exist on standard Linux
|
||||
want: []string{"xdg-open", "https://example.com/path?a=1&b=2"},
|
||||
},
|
||||
{
|
||||
|
|
@ -39,7 +39,7 @@ func TestForOS(t *testing.T) {
|
|||
goos: "linux",
|
||||
url: "https://example.com/path?a=1&b=2",
|
||||
},
|
||||
findExe: false,
|
||||
findExe: true, // wslview exists on WSL
|
||||
want: []string{"wslview", "https://example.com/path?a=1&b=2"},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue