Skip to content

Commit

Permalink
Merge pull request #1917 from Accenture/bug/1916-deleting-dataextensi…
Browse files Browse the repository at this point in the history
…onfield-with-in-name-does-not-work

bug/1916 fix keys with ":" cannot be found
  • Loading branch information
JoernBerkefeld authored Dec 6, 2024
2 parents dfb82fb + ba70eae commit b92241a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion @types/lib/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 26 additions & 9 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2221,36 +2221,53 @@ class Mcdev {
}
const metadataOptionMap = metadataOption.map((item) => {
const itemArr = item.split(':');
const type = itemArr.shift();
switch (itemArr.length) {
case 1: {
return { type: itemArr[0] };
case 0: {
// no ":" found
return { type };
}
case 2: {
case 1: {
// 1 ":" found
if (allowedIdentifiers.includes('key')) {
return { type: itemArr[0], key: itemArr[1] };
return { type, key: itemArr[0] };
}
break;
}
case 3: {
switch (itemArr[1]) {
default: {
// 2 or more ":" found
switch (itemArr[0]) {
case 'key':
case 'k': {
if (allowedIdentifiers.includes('key')) {
return { type: itemArr[0], key: itemArr[2] };
// remove k/key
itemArr.shift();
return { type, key: itemArr.join(':') };
}
break;
}
case 'id':
case 'i': {
if (allowedIdentifiers.includes('id')) {
return { type: itemArr[0], id: itemArr[2] };
// remove i/id
itemArr.shift();
return { type, id: itemArr.join(':') };
}
break;
}
case 'name':
case 'n': {
if (allowedIdentifiers.includes('name')) {
return { type: itemArr[0], name: itemArr[2] };
// remove n/name
itemArr.shift();
return { type, name: itemArr.join(':') };
}
break;
}
default: {
// assume ":" is part of the key (e.g. possible for DE-fields)
if (allowedIdentifiers.includes('key')) {
return { type, key: itemArr.join(':') };
}
}
}
Expand Down

0 comments on commit b92241a

Please sign in to comment.