From 723927f2dcdcc425025da03ac0be5edd3c203dc7 Mon Sep 17 00:00:00 2001 From: Piotr Grzesik Date: Mon, 8 Nov 2021 14:09:38 +0100 Subject: [PATCH] feat(Variables): Recognize `:` in address to support `output` source --- lib/configuration/variables/parse.js | 5 ----- test/unit/lib/configuration/variables/parse.test.js | 12 ++++++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/configuration/variables/parse.js b/lib/configuration/variables/parse.js index c43eb09cf2f..c487304529b 100644 --- a/lib/configuration/variables/parse.js +++ b/lib/configuration/variables/parse.js @@ -426,11 +426,6 @@ module.exports = (inputValue) => { contextVariables ); finalizeSource(); - } else if (char === ':') { - throw new ServerlessError( - `Invalid variable address at index ${sourceStart} in "${value}"`, - 'INVALID_VARIABLE_ADDRESS' - ); } break; case 'afterAddressString': diff --git a/test/unit/lib/configuration/variables/parse.test.js b/test/unit/lib/configuration/variables/parse.test.js index db7a776dda7..0cdd8ceb809 100644 --- a/test/unit/lib/configuration/variables/parse.test.js +++ b/test/unit/lib/configuration/variables/parse.test.js @@ -32,6 +32,12 @@ describe('test/unit/lib/configuration/variables/parse.test.js', () => { { sources: [{ type: 'type', address: { value: 'address' } }] }, ])); + // ${type:address:with:colons} + it('should support type and address with colons', () => + expect(parse('${type:address:with:colons}')).to.deep.equal([ + { sources: [{ type: 'type', address: { value: 'address:with:colons' } }] }, + ])); + // ${type(param)} it('should support param', () => expect(parse('${type(param)}')).to.deep.equal([ @@ -394,12 +400,6 @@ describe('test/unit/lib/configuration/variables/parse.test.js', () => { .to.throw(ServerlessError) .with.property('code', 'INVALID_VARIABLE_TYPE')); - // ${type:foo:bar} - it('should reject ":" strings in address literal', () => - expect(() => parse('${type:foo:bar}')) - .to.throw(ServerlessError) - .with.property('code', 'INVALID_VARIABLE_ADDRESS')); - // ${type:address it('should detect not closed variable', () => { expect(() => parse('${type:address'))