mirror of
https://github.com/TwiN/gatus.git
synced 2024-12-14 11:58:04 +00:00
Fix pattern issue
This commit is contained in:
parent
77737dbab6
commit
e89bb932ea
1 changed files with 5 additions and 4 deletions
|
@ -10,10 +10,11 @@ func Match(pattern, s string) bool {
|
||||||
if pattern == "*" {
|
if pattern == "*" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// Backslashes break filepath.Match, so we'll remove all of them.
|
// Separators found in the string break filepath.Match, so we'll remove all of them.
|
||||||
// This has a pretty significant impact on performance when there
|
// This has a pretty significant impact on performance when there are separators in
|
||||||
// are backslashes, but at least it doesn't break filepath.Match.
|
// the strings, but at least it doesn't break filepath.Match.
|
||||||
s = strings.ReplaceAll(s, "\\", "")
|
s = strings.ReplaceAll(s, string(filepath.Separator), "")
|
||||||
|
pattern = strings.ReplaceAll(pattern, string(filepath.Separator), "")
|
||||||
matched, _ := filepath.Match(pattern, s)
|
matched, _ := filepath.Match(pattern, s)
|
||||||
return matched
|
return matched
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue