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

21 lines
377 B
Go
Raw Normal View History

2026-05-22 20:26:11 -04:00
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) + "%"
}