Skip to content

Commit 3ebadb9

Browse files
fix: allow for content source maps to work with preview.eu.contentful.com (#2545)
Co-authored-by: Bram Kaashoek <[email protected]>
1 parent 1d54463 commit 3ebadb9

File tree

6 files changed

+13
-7
lines changed

6 files changed

+13
-7
lines changed

lib/utils/validate-params.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ export function checkIncludeContentSourceMapsParamIsAllowed(
6464
)
6565
}
6666

67-
const includeContentSourceMapsIsAllowed = host === 'preview.contentful.com'
67+
const includeContentSourceMapsIsAllowed = typeof host === 'string' && host.startsWith('preview')
6868

6969
if (includeContentSourceMaps && !includeContentSourceMapsIsAllowed) {
7070
throw new ValidationError(
7171
'includeContentSourceMaps',
72-
`The 'includeContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' to include Content Source Maps.
72+
`The 'includeContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' or 'preview.eu.contentful.com' to include Content Source Maps.
7373
`,
7474
)
7575
}
@@ -92,7 +92,7 @@ export function checkEnableTimelinePreviewIsAllowed(
9292
if (isValidConfig && !isValidHost) {
9393
throw new ValidationError(
9494
'timelinePreview',
95-
`The 'timelinePreview' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' to enable Timeline Preview.
95+
`The 'timelinePreview' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' or 'preview.eu.contentful.com' to enable Timeline Preview.
9696
`,
9797
)
9898
}

test/integration/getAsset.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('getAsset', () => {
4040
describe('has includeContentSourceMaps enabled', () => {
4141
test('cdn client', async () => {
4242
await expect(invalidClient.getAsset(asset)).rejects.toThrow(
43-
`The 'includeContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' to include Content Source Maps.`,
43+
`The 'includeContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' or 'preview.eu.contentful.com' to include Content Source Maps.`,
4444
)
4545
await expect(invalidClient.getAsset(asset)).rejects.toThrow(ValidationError)
4646
})

test/integration/getAssets.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('getAssets', () => {
4848
describe('has includeContentSourceMaps enabled', () => {
4949
test('cdn client', async () => {
5050
await expect(invalidClient.getAssets()).rejects.toThrow(
51-
`The 'includeContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' to include Content Source Maps.`,
51+
`The 'includeContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' or 'preview.eu.contentful.com' to include Content Source Maps.`,
5252
)
5353
await expect(invalidClient.getAssets()).rejects.toThrow(ValidationError)
5454
})

test/integration/getEntries.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ describe('getEntries via client chain modifiers', () => {
385385
describe('has includeContentSourceMaps enabled', () => {
386386
test('invalid client', async () => {
387387
await expect(invalidClient.getEntries()).rejects.toThrow(
388-
`The 'includeContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' to include Content Source Maps.`,
388+
`The 'includeContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' or 'preview.eu.contentful.com' to include Content Source Maps.`,
389389
)
390390
await expect(invalidClient.getEntries()).rejects.toThrow(ValidationError)
391391
})

test/integration/getEntry.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ describe('getEntry via client chain modifiers', () => {
197197
describe('preview client has includeContentSourceMaps enabled', () => {
198198
test('invalid client', async () => {
199199
await expect(invalidClient.getEntry(entryWithResolvableLink)).rejects.toThrow(
200-
`The 'includeContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' to include Content Source Maps.`,
200+
`The 'includeContentSourceMaps' parameter can only be used with the CPA. Please set host to 'preview.contentful.com' or 'preview.eu.contentful.com' to include Content Source Maps.`,
201201
)
202202
await expect(invalidClient.getEntry(entryWithResolvableLink)).rejects.toThrow(ValidationError)
203203
})

test/unit/utils/validate-params.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ describe('checkIncludeContentSourceMapsParamIsAllowed', () => {
2626
expect(checkIncludeContentSourceMapsParamIsAllowed('preview.contentful.com', true)).toBe(true)
2727
})
2828

29+
it('returns true if includeContentSourceMaps is true and host is preview.eu.contentful.com', () => {
30+
expect(checkIncludeContentSourceMapsParamIsAllowed('preview.eu.contentful.com', true)).toBe(
31+
true,
32+
)
33+
})
34+
2935
it('returns false if includeContentSourceMaps is false, regardless of host', () => {
3036
expect(checkIncludeContentSourceMapsParamIsAllowed('preview.contentful.com', false)).toBe(false)
3137
expect(checkIncludeContentSourceMapsParamIsAllowed('cdn.contentful.com', false)).toBe(false)

0 commit comments

Comments
 (0)