From 1a9cdf356b8e9d05a7a29b8a7f4c289e5682c6a1 Mon Sep 17 00:00:00 2001 From: exoego Date: Thu, 6 Dec 2018 21:36:00 +0900 Subject: [PATCH] Remove whitespace-celaning that seems unnecessary. --- lib/classes/Variables.js | 2 +- lib/classes/Variables.test.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/classes/Variables.js b/lib/classes/Variables.js index 6411f043f..084f275a5 100644 --- a/lib/classes/Variables.js +++ b/lib/classes/Variables.js @@ -268,7 +268,7 @@ class Variables { return match.replace( this.variableSyntax, (context, contents) => contents.trim() - ).replace(/\s/g, ''); + ); } /** * @typedef {Object} MatchResult diff --git a/lib/classes/Variables.test.js b/lib/classes/Variables.test.js index 19c68a8e3..2c65f39a4 100644 --- a/lib/classes/Variables.test.js +++ b/lib/classes/Variables.test.js @@ -634,6 +634,16 @@ describe('Variables', () => { return serverless.variables.populateObject(service.custom) .should.become(expected); }); + it('should preserve whitespace in literal fallback', () => { + service.custom = { + val0: '${self:custom.val, "rate(3 hours)"}', + }; + const expected = { + val0: 'rate(3 hours)', + }; + return serverless.variables.populateObject(service.custom) + .should.become(expected); + }); it('should handle deep variables regardless of custom variableSyntax', () => { service.provider.variableSyntax = '\\${{([ ~:a-zA-Z0-9._\\\'",\\-\\/\\(\\)]+?)}}'; serverless.variables.loadVariableSyntax();