Skip to content

Commit

Permalink
Prevent exception when trying to retrieve semantic ids
Browse files Browse the repository at this point in the history
  • Loading branch information
de-ich committed Dec 6, 2024
1 parent 6086a75 commit 9175506
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions capability-check/aasUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,27 @@ const getChildren = (parent) => {
}

const getSemanticIdAsSingleKey = (element) => {
if (!element.semanticId) {
if (!element?.semanticId) {
return null;
}

return getReferenceAsSingleKey(element.semanticId);
}

const getSupplementarySemanticIdsAsSingleKeys = (element) => {
if (!element.supplementalSemanticIds) {
if (!element?.supplementalSemanticIds) {
return null;
}

return element.supplementalSemanticIds.map(id => getReferenceAsSingleKey(id));
}

const getReferenceAsSingleKey = (reference) => {

if (!reference?.keys) {
return null;
}

const keys = reference.keys;
return keys[keys.length - 1].value;
}
Expand Down

0 comments on commit 9175506

Please sign in to comment.