| 1 | /* |
| 2 | Copyright 2020 The Kubernetes Authors. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package utilscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/util`/ |
| 18 | |
| 19 | import ( |
| 20 | "bytesscip-go gomod github.com/golang/go/src go1.23.6 bytes/" |
| 21 | "fmtscip-go gomod github.com/golang/go/src go1.23.6 fmt/" |
| 22 | "net/urlscip-go gomod github.com/golang/go/src go1.23.6 `net/url`/" |
| 23 | "stringsscip-go gomod github.com/golang/go/src go1.23.6 strings/" |
| 24 | ) |
| 25 | |
| 26 | // PrettyPrintURL decodes the URL encoded input string and print each key=val |
| 27 | // pair separated by comma |
| 28 | func PrettyPrintURLscip-go gomod sigs.k8s.io/apiserver-network-proxy . `sigs.k8s.io/apiserver-network-proxy/pkg/util`/PrettyPrintURL().(urlEncode string) string { |
| 29 | decoded, _ := urlscip-go gomod github.com/golang/go/src go1.23.6 `net/url`/.ParseQueryscip-go gomod github.com/golang/go/src go1.23.6 `net/url`/ParseQuery().(urlEncode) |
| 30 | var buf bytesscip-go gomod github.com/golang/go/src go1.23.6 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.23.6 bytes/Buffer# |
| 31 | for key, val := range decoded { |
| 32 | for _, subVal := range val { |
| 33 | buf.WriteStringscip-go gomod github.com/golang/go/src go1.23.6 bytes/Buffer#WriteString().(fmtscip-go gomod github.com/golang/go/src go1.23.6 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.23.6 fmt/Sprintf().("%s=%s,", key, subVal)) |
| 34 | } |
| 35 | } |
| 36 | return stringsscip-go gomod github.com/golang/go/src go1.23.6 strings/.TrimSuffixscip-go gomod github.com/golang/go/src go1.23.6 strings/TrimSuffix().(buf.Stringscip-go gomod github.com/golang/go/src go1.23.6 bytes/Buffer#String().(), ",") |
| 37 | } |