This commit is contained in:
huangcheng 2025-05-05 20:41:51 +00:00 committed by GitHub
commit 135982fb8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View File

@ -542,6 +542,22 @@ describe('KeepAlive', () => {
await assertNameMatch({ include: 'one,two', exclude: 'two' })
})
test('include + exclude with space before commas', async () => {
await assertNameMatch({ include: 'one ,two', exclude: 'two' })
})
test('include + exclude with space after commas', async () => {
await assertNameMatch({ include: 'one, two', exclude: 'two' })
})
test('include + exclude with space around comma', async () => {
await assertNameMatch({ include: 'one , two', exclude: 'two' })
})
test('include + exclude with space at both ends', async () => {
await assertNameMatch({ include: ' one , two ', exclude: ' two ' })
})
test('max', async () => {
const spyAC = vi.fn()
const spyBC = vi.fn()

View File

@ -390,7 +390,10 @@ function matches(pattern: MatchPattern, name: string): boolean {
if (isArray(pattern)) {
return pattern.some((p: string | RegExp) => matches(p, name))
} else if (isString(pattern)) {
return pattern.split(',').includes(name)
return pattern
.trim()
.split(/\s*,\s*/)
.includes(name)
} else if (isRegExp(pattern)) {
pattern.lastIndex = 0
return pattern.test(name)