Skip to content

Commit

Permalink
Merge pull request serverless#2774 from serverless/apig-var-bug
Browse files Browse the repository at this point in the history
fixed breaking change with apig resource with variable
  • Loading branch information
eahefnawy authored Nov 23, 2016
2 parents e702b75 + be9e098 commit 1e0f19e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions lib/plugins/aws/lib/naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
10 changes: 5 additions & 5 deletions lib/plugins/aws/lib/naming.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('#naming()', () => {
});
});

describe('#normalizeNameToCapitalAlphaNumbericOnly()', () => {
describe('#normalizePathPart()', () => {
it('converts `-` to `Dash`', () => {
expect(sdk.naming.normalizePathPart(
'a-path'
Expand All @@ -57,10 +57,10 @@ 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');
)).to.equal('VariableVarpath');
});

it('converts variable declarations suffixes to `PathvariableVar`', () => {
Expand All @@ -69,10 +69,10 @@ 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');
)).to.equal('PathvariableVardir');
});
});

Expand Down

0 comments on commit 1e0f19e

Please sign in to comment.