[BUGFIX] Removing extra quotation added on --format
* Turns out the quotation is a part of "?format=" so it got removed * Added a nice bonus of replacing spaces in --format with their proper URL value
This commit is contained in:
parent
52f25ed46d
commit
34fd79b312
1 changed files with 5 additions and 3 deletions
8
main.go
8
main.go
|
@ -7,6 +7,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -121,10 +122,11 @@ func generateParamFormat(switchesF []*bool, freeStyleF *string, formatF *string,
|
||||||
|
|
||||||
// If --format is specified, let's return the format the user wants
|
// If --format is specified, let's return the format the user wants
|
||||||
if *formatF != "" {
|
if *formatF != "" {
|
||||||
|
re := regexp.MustCompile("\\s")
|
||||||
var str strings.Builder
|
var str strings.Builder
|
||||||
str.WriteString("?format=\"")
|
|
||||||
str.WriteString(*formatF)
|
str.WriteString("?format=")
|
||||||
str.WriteString("\"")
|
str.WriteString(re.ReplaceAllString(*formatF, "%20"))
|
||||||
return str.String(), downloadMode, nil
|
return str.String(), downloadMode, nil
|
||||||
}
|
}
|
||||||
// If --one-liner is specified, we know the format is set so let's return it
|
// If --one-liner is specified, we know the format is set so let's return it
|
||||||
|
|
Loading…
Reference in a new issue