Skip to content

Commit

Permalink
fix #252
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
  • Loading branch information
jkowalleck committed Feb 11, 2022
1 parent 26056b0 commit c5e9ec0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion model/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ class Component extends CycloneDXObject {

// endregion optional properties

/**
* @returns {string}
*/
static get EMPTY_NAME_FALLBACK () { return 'NO-NAME-COMPONENT' }

/**
* @param {(object|undefined)} [pkg]
* @param {boolean} [includeLicenseText]
Expand All @@ -95,7 +100,7 @@ class Component extends CycloneDXObject {
// use the setters wherever type checks are needed, as the input data is untrusted and potentially malformed.
const pkgIdentifier = parsePackageJsonName(pkg.name)

this.name = pkgIdentifier.fullName
this.name = pkgIdentifier.fullName || Component.EMPTY_NAME_FALLBACK

this.type = this.determinePackageType(pkg)

Expand Down Expand Up @@ -133,6 +138,7 @@ class Component extends CycloneDXObject {
// bomRef defaults to PURL for backwards compatibility reasons
this.bomRef = this.purl
} else {
this.name = Component.EMPTY_NAME_FALLBACK
this.#hashes = new HashList()
this.#externalReferences = new ExternalReferenceList()
}
Expand Down

0 comments on commit c5e9ec0

Please sign in to comment.