mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Added HTTP/HTTPS handling in OpenFile() function in wtf/utils.go to manage proper URL openings
This commit is contained in:
parent
1d888118c5
commit
5adfbfb066
22
wtf/utils.go
22
wtf/utils.go
@ -7,6 +7,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
//"sync"
|
//"sync"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
@ -95,11 +96,22 @@ func NamesFromEmails(emails []string) []string {
|
|||||||
|
|
||||||
// OpenFile opens the file defined in `path` via the operating system
|
// OpenFile opens the file defined in `path` via the operating system
|
||||||
func OpenFile(path string) {
|
func OpenFile(path string) {
|
||||||
filePath, _ := ExpandHomeDir(path)
|
if (strings.HasPrefix(path,"http://"))||(strings.HasPrefix(path,"https://")) {
|
||||||
openFileUtil := Config.UString("wtf.openFileUtil", "open")
|
switch runtime.GOOS {
|
||||||
cmd := exec.Command(openFileUtil, filePath)
|
case "linux":
|
||||||
|
exec.Command("xdg-open", path).Start()
|
||||||
ExecuteCommand(cmd)
|
case "windows":
|
||||||
|
exec.Command("rundll32", "url.dll,FileProtocolHandler", path).Start()
|
||||||
|
case "darwin":
|
||||||
|
exec.Command("open", path).Start()
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
filePath, _ := ExpandHomeDir(path)
|
||||||
|
openFileUtil := Config.UString("wtf.openFileUtil", "open")
|
||||||
|
cmd := exec.Command(openFileUtil, filePath)
|
||||||
|
ExecuteCommand(cmd)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PadRow returns a padding for a row to make it the full width of the containing widget.
|
// PadRow returns a padding for a row to make it the full width of the containing widget.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user