diff --git a/packages/amis-core/__tests__/scoped.test.ts b/packages/amis-core/__tests__/scoped.test.ts index 99c998c912c..00b87c5d0a5 100644 --- a/packages/amis-core/__tests__/scoped.test.ts +++ b/packages/amis-core/__tests__/scoped.test.ts @@ -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]}']); diff --git a/packages/amis-core/src/Scoped.tsx b/packages/amis-core/src/Scoped.tsx index 2bd0cfc06f0..d3d24cc045f 100644 --- a/packages/amis-core/src/Scoped.tsx +++ b/packages/amis-core/src/Scoped.tsx @@ -68,7 +68,7 @@ export function splitTarget(target: string): Array { let parts: Array = []; pos.reduceRight((arr: Array, index) => { - arr.unshift(target.slice(index + 1)); + arr.unshift(target.slice(index + 1)?.trim()); target = target.slice(0, index); return arr; }, parts);