From 296c95039d4cf72b6e5007aa2fa0b14c1c71fa89 Mon Sep 17 00:00:00 2001 From: lvxiaojiao Date: Wed, 21 Feb 2024 14:32:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:scope=E5=91=BD=E4=B8=AD=E5=A4=9A=E7=9B=AE?= =?UTF-8?q?=E6=A0=87=E5=85=BC=E5=AE=B9=E7=A9=BA=E6=A0=BC=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/__tests__/scoped.test.ts | 1 + packages/amis-core/src/Scoped.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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);