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

Method parsePathOptions

options/parser/processing_options.go:223–255  ·  view source on GitHub ↗

parsePathOptions parses processing options from the URL path

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

Source from the content-addressed store, hash-verified

221
222// parsePathOptions parses processing options from the URL path
223func (p *Parser) parsePathOptions(
224 ctx context.Context,
225 parts []string,
226 features *clientfeatures.Features,
227) (*options.Options, string, error) {
228 if _, ok := processing.ResizeTypes[parts[0]]; ok {
229 return nil, "", newInvalidURLError(ctx, "It looks like you're using the deprecated basic URL format")
230 }
231
232 o, err := p.defaultProcessingOptions(ctx, features)
233 if err != nil {
234 return nil, "", err
235 }
236
237 urlOpts, urlParts := p.parseURLOptions(parts)
238
239 if err = p.applyURLOptions(ctx, o, urlOpts, false); err != nil {
240 return nil, "", err
241 }
242
243 url, extension, err := p.DecodeURL(ctx, urlParts)
244 if err != nil {
245 return nil, "", err
246 }
247
248 if !options.Get(o, keys.Raw, false) && len(extension) > 0 {
249 if err = p.applyFormatOption(ctx, o, []string{extension}); err != nil {
250 return nil, "", err
251 }
252 }
253
254 return o, url, nil
255}
256
257// parsePathPresets parses presets from the URL path
258func (p *Parser) parsePathPresets(

Callers 1

ParsePathMethod · 0.95

Calls 7

parseURLOptionsMethod · 0.95
applyURLOptionsMethod · 0.95
DecodeURLMethod · 0.95
applyFormatOptionMethod · 0.95
GetFunction · 0.92
newInvalidURLErrorFunction · 0.85

Tested by

no test coverage detected