contentful 11.12.3 → 11.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -55,8 +55,13 @@ function checkEnableTimelinePreviewIsAllowed(host, timelinePreview) {
|
|
|
55
55
|
}
|
|
56
56
|
const isValidConfig = isValidTimelinePreviewConfig(timelinePreview);
|
|
57
57
|
// Show error if used outside of CPA.
|
|
58
|
-
// Opt-out of the error if a custom domain is used and CPA could not be
|
|
59
|
-
|
|
58
|
+
// Opt-out of the error if a custom domain is used and CPA could not be identified.
|
|
59
|
+
// Use an exact domain match to avoid false-positives on proxy hostnames that contain
|
|
60
|
+
// "contentful" as a substring (e.g. api-contentful-proxy.example.com).
|
|
61
|
+
const PREVIEW_HOST_REGEX = /^preview(\.eu)?\.contentful\.com$/;
|
|
62
|
+
const isContentfulHost = typeof host === 'string' && PREVIEW_HOST_REGEX.test(host);
|
|
63
|
+
const isCustomHost = typeof host !== 'string' || !host.endsWith('.contentful.com');
|
|
64
|
+
const isValidHost = isContentfulHost || isCustomHost;
|
|
60
65
|
if (isValidConfig && !isValidHost) {
|
|
61
66
|
throw new ValidationError('timelinePreview', `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.
|
|
62
67
|
`);
|