Merge pull request #9630 from hsm-lv/fix-scope

fix:scope命中多目标兼容空格情况
This commit is contained in:
hsm-lv 2024-02-21 14:54:24 +08:00 committed by GitHub
commit 7e03085faf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -11,6 +11,7 @@ import {makeEnv} from './helper';
test('Scoped splitTarget', async () => {
expect(splitTarget('abc')).toEqual(['abc']);
expect(splitTarget('a,b,c')).toEqual(['a', 'b', 'c']);
expect(splitTarget('a, b, c ')).toEqual(['a', 'b', 'c']);
expect(splitTarget('a?x=1&y=2,b,c')).toEqual(['a?x=1&y=2', 'b', 'c']);
expect(splitTarget('a?x=${[a, b]},b,c')).toEqual(['a?x=${[a, b]}', 'b', 'c']);
expect(splitTarget('a?x=${[a, b]}')).toEqual(['a?x=${[a, b]}']);

View File

@ -68,7 +68,7 @@ export function splitTarget(target: string): Array<string> {
let parts: Array<string> = [];
pos.reduceRight((arr: Array<string>, index) => {
arr.unshift(target.slice(index + 1));
arr.unshift(target.slice(index + 1)?.trim());
target = target.slice(0, index);
return arr;
}, parts);