Skip to content

Commit 18cfbf8

Browse files
authored
Merge pull request #95 from DianaIonita/bug/issue94
2 parents 239a597 + f90abc6 commit 18cfbf8

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/stageCache.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const httpEventOf = (lambda, endpointSettings) => {
106106
}
107107
});
108108

109-
return httpEvents.filter(e => e.path = endpointSettings.path || "/" + e.path === endpointSettings.path)
109+
return httpEvents.filter(e => (e.path === endpointSettings.path) || (`/${e.path}` === endpointSettings.path))
110110
.filter(e => e.method.toUpperCase() == endpointSettings.method.toUpperCase());
111111
}
112112

test/updating-stage-cache-settings.js

+28
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,34 @@ describe('Updating stage cache settings', () => {
667667
});
668668
});
669669

670+
describe('when an http endpoint path is empty', () => {
671+
before(async () => {
672+
let endpoint = given.a_serverless_function('list-cats')
673+
.withHttpEndpoint('get', '', { enabled: true });
674+
675+
serverless = given.a_serverless_instance()
676+
.withApiGatewayCachingConfig()
677+
.withFunction(endpoint)
678+
.forStage('somestage');
679+
settings = new ApiGatewayCachingSettings(serverless);
680+
681+
restApiId = await given.a_rest_api_id_for_deployment(serverless, settings);
682+
683+
await when_updating_stage_cache_settings(settings, serverless);
684+
685+
requestsToAws = serverless.getRequestsToAws();
686+
apiGatewayRequest = requestsToAws.find(r => r.awsService == apiGatewayService && r.method == updateStageMethod);
687+
});
688+
689+
it(`should enable caching for the endpoint`, () => {
690+
expect(apiGatewayRequest.properties.patchOperations).to.deep.include({
691+
op: 'replace',
692+
path: `/~1/GET/caching/enabled`,
693+
value: 'true'
694+
});
695+
});
696+
});
697+
670698
// https://github.com/DianaIonita/serverless-api-gateway-caching/issues/46
671699
describe('When there are over twenty two http endpoints defined', () => {
672700
let requestsToAwsToUpdateStage, restApiId, expectedStageName;

0 commit comments

Comments
 (0)