[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:
Elia el Lazkani 2020-03-01 11:07:18 +01:00
parent 52f25ed46d
commit 34fd79b312

View file

@ -7,6 +7,7 @@ import (
"log"
"net/http"
"os"
"regexp"
"strconv"
"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 *formatF != "" {
re := regexp.MustCompile("\\s")
var str strings.Builder
str.WriteString("?format=\"")
str.WriteString(*formatF)
str.WriteString("\"")
str.WriteString("?format=")
str.WriteString(re.ReplaceAllString(*formatF, "%20"))
return str.String(), downloadMode, nil
}
// If --one-liner is specified, we know the format is set so let's return it