mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
fix: Websocket route names normalization (#7294)
This commit is contained in:
parent
024146885a
commit
33291c8d08
@ -208,11 +208,11 @@ module.exports = {
|
||||
|
||||
getNormalizedWebsocketsRouteKey(route) {
|
||||
return route
|
||||
.replace('$', 'S') // dollar sign
|
||||
.replace('/', 'Slash')
|
||||
.replace('-', 'Dash')
|
||||
.replace('_', 'Underscore')
|
||||
.replace('.', 'Period');
|
||||
.replace(/\$/g, 'S') // dollar sign
|
||||
.replace(/\//g, 'Slash')
|
||||
.replace(/-/g, 'Dash')
|
||||
.replace(/_/g, 'Underscore')
|
||||
.replace(/\./g, 'Period');
|
||||
},
|
||||
|
||||
getWebsocketsRouteLogicalId(route) {
|
||||
|
||||
@ -253,6 +253,18 @@ describe('#naming()', () => {
|
||||
|
||||
expect(sdk.naming.getNormalizedWebsocketsRouteKey('foo.bar')).to.equal('fooPeriodbar');
|
||||
});
|
||||
|
||||
it('converts multiple `-` correctly', () => {
|
||||
expect(sdk.naming.getNormalizedWebsocketsRouteKey('a-longer-path')).to.equal(
|
||||
'aDashlongerDashpath'
|
||||
);
|
||||
});
|
||||
|
||||
it('converts multiple `-` and `_` correctly', () => {
|
||||
expect(sdk.naming.getNormalizedWebsocketsRouteKey('a-long_er-path_still')).to.equal(
|
||||
'aDashlongUnderscoreerDashpathUnderscorestill'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getWebsocketsRouteLogicalId()', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user