diff options
| author | Martin Fischer <martin@push-f.com> | 2026-01-17 11:44:34 +0100 |
|---|---|---|
| committer | Martin Fischer <martin@push-f.com> | 2026-01-17 11:54:35 +0100 |
| commit | 4eae890b11b743cbdcf68ee185d67bce873076dc (patch) | |
| tree | 4f01c4f507306feec72977582d0e3bae9c805295 | |
| parent | db778877e6273c3d878eb9f3858531ddfb68242c (diff) | |
fix(open): make URI scheme matching case-insensitive
| -rw-r--r-- | programs/open/main.go | 7 | ||||
| -rw-r--r-- | programs/open/main_test.go | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/programs/open/main.go b/programs/open/main.go index ad3c3ca..f193f3f 100644 --- a/programs/open/main.go +++ b/programs/open/main.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "mime" + "net/url" "os" "os/exec" "path" @@ -57,8 +58,10 @@ func main() { } func (c Config) findCommand(arg string) ([]string, error) { - for scheme, cmd := range c.UriSchemes { - if strings.HasPrefix(arg, scheme+":") { + u, err := url.Parse(arg) + if err == nil && u.Scheme != "" { + cmd, ok := c.UriSchemes[u.Scheme] + if ok { return cmd, nil } } diff --git a/programs/open/main_test.go b/programs/open/main_test.go index 213c2e4..57b501f 100644 --- a/programs/open/main_test.go +++ b/programs/open/main_test.go @@ -20,6 +20,7 @@ func TestFindCommand_Uri(t *testing.T) { cases := []string{ "http://example.com", + "hTtP://example.com", "http:example.com", "http:", } |
