mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 16:29:12 +00:00
fix(wildcard): check name length (#1758)
* fix(wildcard): check name length * fix(wildcard): add additional test * fix(wildcard): tests --------- Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
parent
d15b61870e
commit
a64fd779f8
2 changed files with 6 additions and 1 deletions
|
@ -55,7 +55,7 @@ func match(pattern, name string, simple bool) (matched bool) {
|
|||
}
|
||||
|
||||
offset := base + i
|
||||
if name[base:offset] != pattern[base:offset] {
|
||||
if len(name) < offset || name[base:offset] != pattern[base:offset] {
|
||||
break
|
||||
}
|
||||
|
||||
|
|
|
@ -102,6 +102,11 @@ func TestMatch(t *testing.T) {
|
|||
text: "The God of the BrrThe Power of Brr",
|
||||
matched: true,
|
||||
},
|
||||
{
|
||||
pattern: "mysteries?of?the?abandoned*",
|
||||
text: "them",
|
||||
matched: false,
|
||||
},
|
||||
}
|
||||
// Iterating over the test cases, call the function under test and assert the output.
|
||||
for i, testCase := range testCases {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue