mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-03 15:17:25 +00:00
Merge pull request #1548 from Zillode/case-insensitive-ignores
Support case-insensitive ignores (fixes #1511).
This commit is contained in:
commit
b659da8a4b
@ -38,6 +38,13 @@ func Convert(pattern string, flags int) (*regexp.Regexp, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Support case insensitive ignores
|
||||||
|
ignore := strings.TrimPrefix(pattern, "(?i)")
|
||||||
|
if ignore != pattern {
|
||||||
|
flags |= FNM_CASEFOLD
|
||||||
|
pattern = ignore
|
||||||
|
}
|
||||||
|
|
||||||
if flags&FNM_NOESCAPE != 0 {
|
if flags&FNM_NOESCAPE != 0 {
|
||||||
pattern = strings.Replace(pattern, "\\", "\\\\", -1)
|
pattern = strings.Replace(pattern, "\\", "\\\\", -1)
|
||||||
} else {
|
} else {
|
||||||
|
@ -53,6 +53,8 @@ var testcases = []testcase{
|
|||||||
{"**/foo.txt", "bar/baz/foo.txt", FNM_PATHNAME, true},
|
{"**/foo.txt", "bar/baz/foo.txt", FNM_PATHNAME, true},
|
||||||
|
|
||||||
{"foo.txt", "foo.TXT", FNM_CASEFOLD, true},
|
{"foo.txt", "foo.TXT", FNM_CASEFOLD, true},
|
||||||
|
{"foo.txt", "foo.TXT", 0, false},
|
||||||
|
{"(?i)foo.txt", "foo.TXT", 0, true},
|
||||||
|
|
||||||
// These characters are literals in glob, but not in regexp.
|
// These characters are literals in glob, but not in regexp.
|
||||||
{"hey$hello", "hey$hello", 0, true},
|
{"hey$hello", "hey$hello", 0, true},
|
||||||
|
Loading…
Reference in New Issue
Block a user