Skip to content

Commit ecb49fb

Browse files
fix origins with more than one cache behavior
1 parent e864c90 commit ecb49fb

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

__tests__/__snapshots__/custom-url-origin.test.js.snap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Object {
77
"Items": Array [],
88
"Quantity": 0,
99
},
10+
"CacheBehaviors": Object {
11+
"Items": Array [],
12+
"Quantity": 0,
13+
},
1014
"CallerReference": "1566599541192",
1115
"Comment": "",
1216
"DefaultCacheBehavior": Object {
@@ -93,6 +97,10 @@ Object {
9397
exports[`Input origin as a custom url updates distribution 1`] = `
9498
Object {
9599
"DistributionConfig": Object {
100+
"CacheBehaviors": Object {
101+
"Items": Array [],
102+
"Quantity": 0,
103+
},
96104
"DefaultCacheBehavior": Object {
97105
"AllowedMethods": Object {
98106
"CachedMethods": Object {

__tests__/__snapshots__/s3-origin.test.js.snap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Object {
77
"Items": Array [],
88
"Quantity": 0,
99
},
10+
"CacheBehaviors": Object {
11+
"Items": Array [],
12+
"Quantity": 0,
13+
},
1014
"CallerReference": "1566599541192",
1115
"Comment": "",
1216
"DefaultCacheBehavior": Object {
@@ -87,6 +91,10 @@ Object {
8791
"Items": Array [],
8892
"Quantity": 0,
8993
},
94+
"CacheBehaviors": Object {
95+
"Items": Array [],
96+
"Quantity": 0,
97+
},
9098
"CallerReference": "1566599541192",
9199
"Comment": "",
92100
"DefaultCacheBehavior": Object {
@@ -167,6 +175,10 @@ Object {
167175
"Items": Array [],
168176
"Quantity": 0,
169177
},
178+
"CacheBehaviors": Object {
179+
"Items": Array [],
180+
"Quantity": 0,
181+
},
170182
"CallerReference": "1566599541192",
171183
"Comment": "",
172184
"DefaultCacheBehavior": Object {
@@ -243,6 +255,10 @@ Object {
243255
exports[`S3 origins When origin is an S3 bucket URL updates distribution 1`] = `
244256
Object {
245257
"DistributionConfig": Object {
258+
"CacheBehaviors": Object {
259+
"Items": Array [],
260+
"Quantity": 0,
261+
},
246262
"DefaultCacheBehavior": Object {
247263
"AllowedMethods": Object {
248264
"CachedMethods": Object {

lib/parseInputOrigins.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ module.exports = (origins, options) => {
1212
Quantity: 0,
1313
Items: []
1414
}
15-
let distributionCacheBehaviors
15+
16+
const distributionCacheBehaviors = {
17+
Quantity: 0,
18+
Items: []
19+
}
1620

1721
for (const origin of origins) {
1822
const originConfig = getOriginConfig(origin, options)
@@ -44,11 +48,6 @@ module.exports = (origins, options) => {
4448
})
4549
})
4650

47-
distributionCacheBehaviors = {
48-
Quantity: 0,
49-
Items: []
50-
}
51-
5251
distributionCacheBehaviors.Quantity = distributionCacheBehaviors.Quantity + 1
5352
distributionCacheBehaviors.Items.push(cacheBehavior)
5453
}

0 commit comments

Comments
 (0)