Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cyclonedx/model/bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,10 @@ def get_component_by_purl(self, purl: Optional['PackageURL']) -> Optional[Compon
.. deprecated:: next
"""
if purl:
found = [x for x in self.components if x.purl == purl]
if len(found) == 1:
return found[0]
gen = (x for x in self.components if x.purl == purl)
first = next(gen, None)
if first and next(gen, None) is None:
return first

return None

Expand Down