From babed90e6c526206d88d47843fda3c8ac800780a Mon Sep 17 00:00:00 2001 From: "Eslam A. Hefnawy" Date: Wed, 23 Nov 2016 02:42:08 +0700 Subject: [PATCH 1/2] fixed breaking change with apig resource with variable --- lib/plugins/aws/lib/naming.js | 9 ++++++--- lib/plugins/aws/lib/naming.test.js | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/plugins/aws/lib/naming.js b/lib/plugins/aws/lib/naming.js index 2fd5020ede6..de9b501794f 100644 --- a/lib/plugins/aws/lib/naming.js +++ b/lib/plugins/aws/lib/naming.js @@ -12,9 +12,12 @@ module.exports = { return this.normalizeName(name.replace(/[^0-9A-Za-z]/g, '')); }, normalizePathPart(path) { - return this.normalizeNameToAlphaNumericOnly( - path.replace(/-/g, 'Dash') - .replace(/\{(.*)\}/g, '$1Var')); + return _.upperFirst( + _.capitalize(path) + .replace(/-/g, 'Dash') + .replace(/\{(.*)\}/g, '$1Var') + .replace(/[^0-9A-Za-z]/g, '') + ); }, getServiceEndpointRegex() { diff --git a/lib/plugins/aws/lib/naming.test.js b/lib/plugins/aws/lib/naming.test.js index 7a106f9d1b7..6e9a7b32c37 100644 --- a/lib/plugins/aws/lib/naming.test.js +++ b/lib/plugins/aws/lib/naming.test.js @@ -44,7 +44,7 @@ describe('#naming()', () => { }); }); - describe('#normalizeNameToCapitalAlphaNumbericOnly()', () => { + describe('#normalizePathPart()', () => { it('converts `-` to `Dash`', () => { expect(sdk.naming.normalizePathPart( 'a-path' @@ -60,7 +60,7 @@ describe('#naming()', () => { it('converts variable declarations prefixes to `VariableVarPath`', () => { expect(sdk.naming.normalizePathPart( '${variable}Path' - )).to.equal('VariableVarPath'); + )).to.equal('VariableVarpath'); }); it('converts variable declarations suffixes to `PathvariableVar`', () => { @@ -72,7 +72,7 @@ describe('#naming()', () => { it('converts variable declarations in center to `PathvariableVarDir`', () => { expect(sdk.naming.normalizePathPart( 'path${variable}Dir' - )).to.equal('PathvariableVarDir'); + )).to.equal('PathvariableVardir'); }); }); From be9e0983634b86368c3d59ad5c4a1cb40956b74e Mon Sep 17 00:00:00 2001 From: "Eslam A. Hefnawy" Date: Wed, 23 Nov 2016 02:49:57 +0700 Subject: [PATCH 2/2] fix typo --- lib/plugins/aws/lib/naming.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plugins/aws/lib/naming.test.js b/lib/plugins/aws/lib/naming.test.js index 6e9a7b32c37..6051fa5853a 100644 --- a/lib/plugins/aws/lib/naming.test.js +++ b/lib/plugins/aws/lib/naming.test.js @@ -57,7 +57,7 @@ describe('#naming()', () => { )).to.equal('VariableVar'); }); - it('converts variable declarations prefixes to `VariableVarPath`', () => { + it('converts variable declarations prefixes to `VariableVarpath`', () => { expect(sdk.naming.normalizePathPart( '${variable}Path' )).to.equal('VariableVarpath'); @@ -69,7 +69,7 @@ describe('#naming()', () => { )).to.equal('PathvariableVar'); }); - it('converts variable declarations in center to `PathvariableVarDir`', () => { + it('converts variable declarations in center to `PathvariableVardir`', () => { expect(sdk.naming.normalizePathPart( 'path${variable}Dir' )).to.equal('PathvariableVardir');