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

Method ParsePath

options/parser/processing_options.go:198–220  ·  view source on GitHub ↗

ParsePath parses the given request path and returns the processing options and image URL

(
	ctx context.Context,
	path string,
	features *clientfeatures.Features,
)

Source from the content-addressed store, hash-verified

196
197// ParsePath parses the given request path and returns the processing options and image URL
198func (p *Parser) ParsePath(
199 ctx context.Context,
200 path string,
201 features *clientfeatures.Features,
202) (o *options.Options, imageURL string, err error) {
203 if path == "" || path == "/" {
204 return nil, "", newInvalidURLError(ctx, "invalid path: %s", path)
205 }
206
207 parts := strings.Split(strings.TrimPrefix(path, "/"), "/")
208
209 if p.config.OnlyPresets {
210 o, imageURL, err = p.parsePathPresets(ctx, parts, features)
211 } else {
212 o, imageURL, err = p.parsePathOptions(ctx, parts, features)
213 }
214
215 if err != nil {
216 return nil, "", errctx.Wrap(err)
217 }
218
219 return o, imageURL, nil
220}
221
222// parsePathOptions parses processing options from the URL path
223func (p *Parser) parsePathOptions(

Calls 5

parsePathPresetsMethod · 0.95
parsePathOptionsMethod · 0.95
WrapFunction · 0.92
newInvalidURLErrorFunction · 0.85
SplitMethod · 0.80