diff --git a/packages/transformers/src/operations/REPLACE_REGEX.js b/packages/transformers/src/operations/REPLACE_REGEX.js index 25aff337..7eba24b1 100644 --- a/packages/transformers/src/operations/REPLACE_REGEX.js +++ b/packages/transformers/src/operations/REPLACE_REGEX.js @@ -1,7 +1,7 @@ import { transformerWithTwoArgs } from './transformer'; export const replace = (value, searchValue, replaceValue) => { - const template = typeof input === 'string' ? searchValue : searchValue.toString(); + const template = typeof searchValue === 'string' ? searchValue : searchValue.toString(); const cleantemplate = template.trim().replace(/^[/]+/, '').replace(/[/]+$/, ''); return value.replace(RegExp(cleantemplate, 'gi'), replaceValue); }; diff --git a/packages/transformers/src/operations/REPLACE_REGEX.spec.js b/packages/transformers/src/operations/REPLACE_REGEX.spec.js index bd4fe036..ffbab866 100644 --- a/packages/transformers/src/operations/REPLACE_REGEX.spec.js +++ b/packages/transformers/src/operations/REPLACE_REGEX.spec.js @@ -13,4 +13,7 @@ describe('REPLACE_REGEX', () => { it('should return new value from string', () => { expect(replace('hello world', '\\s*wo\\w+', '')).toBe('hello'); }); + it('should return new value from number search value', () => { + expect(replace('1', 1, '2')).toBe('2'); + }); });