MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / parseBase64String

Method parseBase64String

options/parser/parse.go:246–264  ·  view source on GitHub ↗

parseBase64String parses a base64-encoded string option value

(
	ctx context.Context,
	o *options.Options,
	key string,
	args ...string,
)

Source from the content-addressed store, hash-verified

244
245// parseBase64String parses a base64-encoded string option value
246func (p *Parser) parseBase64String(
247 ctx context.Context,
248 o *options.Options,
249 key string,
250 args ...string,
251) error {
252 if err := p.ensureMaxArgs(ctx, key, args, 1); err != nil {
253 return err
254 }
255
256 b, err := base64.RawURLEncoding.DecodeString(strings.TrimRight(args[0], "="))
257 if err != nil {
258 return newInvalidArgumentError(ctx, key, args[0], "URL-safe base64-encoded string")
259 }
260
261 o.Set(key, string(b))
262
263 return nil
264}
265
266// parseHexRGBColor parses a hex-encoded RGB color option value
267func (p *Parser) parseHexRGBColor(

Callers 1

applyFilenameOptionMethod · 0.95

Calls 3

ensureMaxArgsMethod · 0.95
newInvalidArgumentErrorFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected