MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / globToRegexp

Function globToRegexp

tests/utils/objectstore/objectstore.go:670–676  ·  view source on GitHub ↗

globToRegexp converts a path glob, where `*` matches any sequence of characters including `/`, into an anchored extended regular expression

(pattern string)

Source from the content-addressed store, hash-verified

668// globToRegexp converts a path glob, where `*` matches any sequence of
669// characters including `/`, into an anchored extended regular expression
670func globToRegexp(pattern string) string {
671 fragments := strings.Split(pattern, "*")
672 for i, fragment := range fragments {
673 fragments[i] = regexp.QuoteMeta(fragment)
674 }
675 return "^" + strings.Join(fragments, ".*") + "$"
676}
677
678// listFilesScript builds a shell script printing every object in the store
679// as a `bucket/key` line, filtered by the glob expressed in the given path.

Callers 1

listFilesScriptFunction · 0.85

Calls 1

JoinMethod · 0.80

Tested by

no test coverage detected