Skip to content
Permalink
Browse files

Merge 63fb130 into 898e876

  • Loading branch information
dschep committed Dec 13, 2018
2 parents 898e876 + 63fb130 commit f828fc0af1ba37f5be7644df54843d8eea396a24
Showing with 17 additions and 1 deletion.
  1. +5 −1 lib/classes/Variables.js
  2. +12 −0 lib/classes/Variables.test.js
@@ -265,10 +265,14 @@ class Variables {
* @returns {string} The cleaned variable match
*/
cleanVariable(match) {
return match.replace(
let cleaned = match.replace(
this.variableSyntax,
(context, contents) => contents.trim()
);
if (!cleaned.match(/".*"/)) {
cleaned = cleaned.replace(/\s/g, '')
}
return cleaned
}
/**
* @typedef {Object} MatchResult
@@ -644,6 +644,18 @@ describe('Variables', () => {
return serverless.variables.populateObject(service.custom)
.should.become(expected);
});
it('should accept whitespace in variables', () => {
service.custom = {
val0: '${self: custom.val}',
val: 'foobar'
};
const expected = {
val: 'foobar',
val0: 'foobar',
};
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();

0 comments on commit f828fc0

Please sign in to comment.
You can’t perform that action at this time.