mirror of https://github.com/helm/helm.git
refactor: replace HasPrefix+TrimPrefix with CutPrefix
Signed-off-by: jinjiadu <jinjiadu@aliyun.com>
This commit is contained in:
parent
39305fc160
commit
6f8e9e09a4
|
@ -170,10 +170,10 @@ func (r *Rules) parseRule(rule string) error {
|
|||
rule = strings.TrimSuffix(rule, "/")
|
||||
}
|
||||
|
||||
if strings.HasPrefix(rule, "/") {
|
||||
if after, ok := strings.CutPrefix(rule, "/"); ok {
|
||||
// Require path matches the root path.
|
||||
p.match = func(n string, _ os.FileInfo) bool {
|
||||
rule = strings.TrimPrefix(rule, "/")
|
||||
rule = after
|
||||
ok, err := filepath.Match(rule, n)
|
||||
if err != nil {
|
||||
slog.Error("failed to compile", "rule", rule, slog.Any("error", err))
|
||||
|
|
Loading…
Reference in New Issue