Files
imgproxy/options/url_options.go
Victor Sokolov 4b05e87274 IMG-57: introduce processing options factory (#1526)
* Intoduced options.Factory

* ProcessingOptionsFactory in processing and watermark

* Clone with testutil.Helper
2025-09-16 17:04:21 +02:00

39 lines
608 B
Go

package options
import (
"strings"
)
type urlOption struct {
Name string
Args []string
}
type urlOptions []urlOption
func (f *Factory) parseURLOptions(opts []string) (urlOptions, []string) {
parsed := make(urlOptions, 0, len(opts))
urlStart := len(opts) + 1
for i, opt := range opts {
args := strings.Split(opt, f.config.ArgumentsSeparator)
if len(args) == 1 {
urlStart = i
break
}
parsed = append(parsed, urlOption{Name: args[0], Args: args[1:]})
}
var rest []string
if urlStart < len(opts) {
rest = opts[urlStart:]
} else {
rest = []string{}
}
return parsed, rest
}