Skip to content

Commit

Permalink
Check for existence of oaData.info (and title/version) (CycloneDX#747)
Browse files Browse the repository at this point in the history
* Adds a check to make sure that info and title/version exists before we try and manipulate them, adds defaults if missing.

Signed-off-by: gbennett <gbennett@squarespace.com>

* Adds a check to make sure that info and title/version exists before we try and manipulate them, adds defaults if missing.

Signed-off-by: gbennett <gbennett@squarespace.com>

* linting

Signed-off-by: gbennett <gbennett@squarespace.com>

---------

Signed-off-by: gbennett <gbennett@squarespace.com>
  • Loading branch information
gbennett-squarespace authored Nov 28, 2023
1 parent 1bfb701 commit c8a8bf6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4680,8 +4680,13 @@ export const parseOpenapiSpecData = function (oaData) {
} catch (e) {
return servlist;
}
const name = oaData.info.title.replace(/ /g, "-");
const version = oaData.info.version || "latest";

const name =
oaData.info && oaData.info.title
? oaData.info.title.replace(/ /g, "-")
: "default-name";
const version =
oaData.info && oaData.info.version ? oaData.info.version : "latest";
const aservice = {
"bom-ref": `urn:service:${name}:${version}`,
name,
Expand Down

0 comments on commit c8a8bf6

Please sign in to comment.