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

Method parsePathPresets

options/parser/processing_options.go:258–287  ·  view source on GitHub ↗

parsePathPresets parses presets from the URL path

(
	ctx context.Context,
	parts []string,
	features *clientfeatures.Features,
)

Source from the content-addressed store, hash-verified

256
257// parsePathPresets parses presets from the URL path
258func (p *Parser) parsePathPresets(
259 ctx context.Context,
260 parts []string,
261 features *clientfeatures.Features,
262) (*options.Options, string, error) {
263 o, err := p.defaultProcessingOptions(ctx, features)
264 if err != nil {
265 return nil, "", err
266 }
267
268 presets := strings.Split(parts[0], p.config.ArgumentsSeparator)
269 urlParts := parts[1:]
270
271 if err = p.applyPresetOption(ctx, o, presets); err != nil {
272 return nil, "", err
273 }
274
275 url, extension, err := p.DecodeURL(ctx, urlParts)
276 if err != nil {
277 return nil, "", err
278 }
279
280 if !options.Get(o, keys.Raw, false) && len(extension) > 0 {
281 if err = p.applyFormatOption(ctx, o, []string{extension}); err != nil {
282 return nil, "", err
283 }
284 }
285
286 return o, url, nil
287}

Callers 1

ParsePathMethod · 0.95

Calls 6

applyPresetOptionMethod · 0.95
DecodeURLMethod · 0.95
applyFormatOptionMethod · 0.95
GetFunction · 0.92
SplitMethod · 0.80

Tested by

no test coverage detected