MCPcopy
hub / github.com/pquerna/otp / EncodeQuery

Function EncodeQuery

internal/encode.go:12–35  ·  view source on GitHub ↗

EncodeQuery is a copy-paste of url.Values.Encode, except it uses %20 instead of + to encode spaces. This is necessary to correctly render spaces in some authenticator apps, like Google Authenticator.

(v url.Values)

Source from the content-addressed store, hash-verified

10// of + to encode spaces. This is necessary to correctly render spaces in some
11// authenticator apps, like Google Authenticator.
12func EncodeQuery(v url.Values) string {
13 if v == nil {
14 return ""
15 }
16 var buf strings.Builder
17 keys := make([]string, 0, len(v))
18 for k := range v {
19 keys = append(keys, k)
20 }
21 sort.Strings(keys)
22 for _, k := range keys {
23 vs := v[k]
24 keyEscaped := url.PathEscape(k) // changed from url.QueryEscape
25 for _, v := range vs {
26 if buf.Len() > 0 {
27 buf.WriteByte('&')
28 }
29 buf.WriteString(keyEscaped)
30 buf.WriteByte('=')
31 buf.WriteString(url.PathEscape(v)) // changed from url.QueryEscape
32 }
33 }
34 return buf.String()
35}

Callers 2

GenerateFunction · 0.92
GenerateFunction · 0.92

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…