From 4392293ed62a7651edc476727727da941339a36a Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Wed, 5 Feb 2025 10:22:04 -0300 Subject: [PATCH] curl method and negative make fixes. --- curl.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/curl.go b/curl.go index a039f41..25c4525 100644 --- a/curl.go +++ b/curl.go @@ -32,15 +32,16 @@ var curl = &cli.Command{ nextIsMethod := false for _, f := range curlFlags { - if strings.HasPrefix(f, "https://") || strings.HasPrefix(f, "http://") { - url = f - } else if f == "--request" || f == "-X" { - nextIsMethod = true - } else if nextIsMethod { + if nextIsMethod { method = f method, _ = strings.CutPrefix(method, `"`) method, _ = strings.CutSuffix(method, `"`) method = strings.ToUpper(method) + } else if strings.HasPrefix(f, "https://") || strings.HasPrefix(f, "http://") { + url = f + } else if f == "--request" || f == "-X" { + nextIsMethod = true + continue } nextIsMethod = false } @@ -77,7 +78,7 @@ var curl = &cli.Command{ } func realCurl() error { - curlFlags = make([]string, 2, len(os.Args)-4) + curlFlags = make([]string, 2, max(len(os.Args)-4, 2)) keyFlags := make([]string, 0, 5) for i := 0; i < len(os.Args[2:]); i++ {