mirror of https://github.com/fiatjaf/nak.git
curl method and negative make fixes.
This commit is contained in:
parent
60d1292f80
commit
4392293ed6
13
curl.go
13
curl.go
|
@ -32,15 +32,16 @@ var curl = &cli.Command{
|
||||||
|
|
||||||
nextIsMethod := false
|
nextIsMethod := false
|
||||||
for _, f := range curlFlags {
|
for _, f := range curlFlags {
|
||||||
if strings.HasPrefix(f, "https://") || strings.HasPrefix(f, "http://") {
|
if nextIsMethod {
|
||||||
url = f
|
|
||||||
} else if f == "--request" || f == "-X" {
|
|
||||||
nextIsMethod = true
|
|
||||||
} else if nextIsMethod {
|
|
||||||
method = f
|
method = f
|
||||||
method, _ = strings.CutPrefix(method, `"`)
|
method, _ = strings.CutPrefix(method, `"`)
|
||||||
method, _ = strings.CutSuffix(method, `"`)
|
method, _ = strings.CutSuffix(method, `"`)
|
||||||
method = strings.ToUpper(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
|
nextIsMethod = false
|
||||||
}
|
}
|
||||||
|
@ -77,7 +78,7 @@ var curl = &cli.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func realCurl() error {
|
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)
|
keyFlags := make([]string, 0, 5)
|
||||||
|
|
||||||
for i := 0; i < len(os.Args[2:]); i++ {
|
for i := 0; i < len(os.Args[2:]); i++ {
|
||||||
|
|
Loading…
Reference in New Issue