Files
silo-server/internal/pathscope/pathscope.go
T

21 lines
377 B
Go

package pathscope
import (
"path/filepath"
"strings"
)
var likeEscaper = strings.NewReplacer(
`\`, `\\`,
`%`, `\%`,
`_`, `\_`,
)
func PrefixLike(pathPrefix string) string {
clean := filepath.Clean(pathPrefix)
if clean == string(filepath.Separator) {
return likeEscaper.Replace(clean) + "%"
}
return likeEscaper.Replace(clean) + string(filepath.Separator) + "%"
}