(ctx *cli.Context, data []byte)
| 117 | } |
| 118 | |
| 119 | func getEncoder(ctx *cli.Context, data []byte) *base64.Encoding { |
| 120 | raw := ctx.Bool("raw") |
| 121 | url := ctx.Bool("url") |
| 122 | isDecode := ctx.Bool("decode") |
| 123 | |
| 124 | // Detect encoding |
| 125 | if isDecode && !ctx.IsSet("raw") && !ctx.IsSet("url") { |
| 126 | raw = !bytes.HasSuffix(bytes.TrimSpace(data), []byte("=")) |
| 127 | url = bytes.Contains(data, []byte("-")) || bytes.Contains(data, []byte("_")) |
| 128 | } |
| 129 | |
| 130 | if raw { |
| 131 | if url { |
| 132 | return base64.RawURLEncoding |
| 133 | } |
| 134 | return base64.RawStdEncoding |
| 135 | } |
| 136 | if url { |
| 137 | return base64.URLEncoding |
| 138 | } |
| 139 | |
| 140 | return base64.StdEncoding |
| 141 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…