From c82d9fa550484f7d0c315128f142ae225f9988e6 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 1 Mar 2019 09:33:38 +0100 Subject: [PATCH] Interpolator fixed. --- src/Squidex/app/framework/utils/interpolator.spec.ts | 6 ++++++ src/Squidex/app/framework/utils/interpolator.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Squidex/app/framework/utils/interpolator.spec.ts b/src/Squidex/app/framework/utils/interpolator.spec.ts index 58de0557c..6da899ee1 100644 --- a/src/Squidex/app/framework/utils/interpolator.spec.ts +++ b/src/Squidex/app/framework/utils/interpolator.spec.ts @@ -21,6 +21,12 @@ describe('interpolate', () => { expect(result).toEqual('hello world'); }); + it('should interpolate with multiple object values', () => { + const result = interpolate('hello ${string1}${string2}', { string1: 'world', string2: '!' }); + + expect(result).toEqual('hello world!'); + }); + it('should interpolate with array value', () => { const result = interpolate('hello ${1}', ['my', 'world']); diff --git a/src/Squidex/app/framework/utils/interpolator.ts b/src/Squidex/app/framework/utils/interpolator.ts index 6f3f88e00..5ad5de24e 100644 --- a/src/Squidex/app/framework/utils/interpolator.ts +++ b/src/Squidex/app/framework/utils/interpolator.ts @@ -8,7 +8,7 @@ import { DateTime } from './date-time'; import { Types } from './types'; -const regex = /\${[^}]+}/; +const regex = /\${[^}]+}/g; export function interpolate(pattern: string, value?: any, shortcut?: string, fallback = 'undefined'): string { const result = pattern.replace(regex, (match: string) => {