Skip to content
Permalink
Browse files

restore support for variable refs with spaces in them

  • Loading branch information
dschep committed Dec 13, 2018
1 parent 898e876 commit 63fb1309d342add08662918fa0a72cc33b0fd4c1
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 63fb130

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