Skip to content

Commit

Permalink
Merge pull request #903 from rsteube/match-trimprefix
Browse files Browse the repository at this point in the history
Match: added TrimPrefix to Match
  • Loading branch information
rsteube committed Aug 13, 2023
2 parents c028db5 + a87a6e3 commit e7ce195
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/match/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ func (m Match) HasPrefix(s, prefix string) bool {
return strings.HasPrefix(s, prefix)
}

func (m Match) TrimPrefix(s, prefix string) string {
if m.HasPrefix(s, prefix) {
return s[len(prefix):]
}
return s
}

var match = CASE_SENSITIVE

func init() {
Expand All @@ -46,8 +53,5 @@ func HasPrefix(s, prefix string) bool {
}

func TrimPrefix(s, prefix string) string {
if HasPrefix(s, prefix) {
return s[len(prefix):]
}
return s
return match.TrimPrefix(s, prefix)
}

0 comments on commit e7ce195

Please sign in to comment.