Skip to content

Commit a6fa968

Browse files
authored
Merge pull request #156 from episerver/bugfix/CMS-46085-asterisk-content-type
Allow asterisk in "mayContainTypes" field
2 parents ef08cfb + 7345d4f commit a6fa968

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { contentType } from '@optimizely/cms-sdk';
2+
3+
export const contentTypeWithRegexProperty = contentType({
4+
key: 'CT_with_asterisk',
5+
baseType: '_page',
6+
displayName: 'CT_with_asterisk',
7+
properties: {},
8+
mayContainTypes: ['*'],
9+
});

__test__/cli-test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"private": "true",
66
"main": "index.js",
77
"scripts": {
8-
"test:manual": "echo \"Error: no test specified\" && exit 1"
8+
"test:manual": "optimizely-cms-cli config push ./content-types.optimizely.config.mjs"
99
},
1010
"dependencies": {
1111
"@optimizely/cms-sdk": "workspace:*",

packages/optimizely-cms-cli/src/utils/mapping.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ export function parseChildContentType(
2525
const duplicates: string[] = [];
2626
const normalized = mayContainTypes.map((entry: any) => {
2727
const key = extractKeyName(entry, parentKey);
28-
// Do not allow keys that start with '_' to be validated against allowedKeys
29-
if (!key.startsWith('_') && allowedKeys && !allowedKeys.has(key)) {
28+
if (
29+
key !== '*' &&
30+
// Do not allow keys that start with '_' to be validated against allowedKeys
31+
!key.startsWith('_') &&
32+
allowedKeys &&
33+
!allowedKeys.has(key)
34+
) {
3035
invalid.push(key);
3136
}
3237
if (seen.has(key)) {

0 commit comments

Comments
 (0)