Address PR comments

This commit is contained in:
Sam Coe 2020-09-16 16:04:58 +02:00
parent dd1c24a20a
commit 7551139caf
No known key found for this signature in database
GPG key ID: 8E322C20F811D086
2 changed files with 6 additions and 10 deletions

View file

@ -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
}

View file

@ -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"},
},
{