@@ -20,6 +20,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
20
20
import type { Sortable } from '../_helpers/sortable'
21
21
import type { SpdxId } from '../spdx'
22
22
import type { Attachment } from './attachment'
23
+ import { BomRef } from './bomRef'
23
24
24
25
/**
25
26
* (SPDX) License Expression.
@@ -59,10 +60,12 @@ export class LicenseExpression {
59
60
}
60
61
61
62
class DisjunctiveLicenseBase {
63
+ bomRef : BomRef
62
64
text ?: Attachment
63
65
#url?: URL | string
64
66
65
67
constructor ( op : OptionalDisjunctiveLicenseProperties = { } ) {
68
+ this . bomRef = new BomRef ( op . bomRef )
66
69
this . text = op . text
67
70
this . url = op . url
68
71
}
@@ -79,6 +82,7 @@ class DisjunctiveLicenseBase {
79
82
}
80
83
81
84
interface OptionalDisjunctiveLicenseProperties {
85
+ bomRef ?: BomRef [ 'value' ]
82
86
text ?: DisjunctiveLicenseBase [ 'text' ]
83
87
url ?: DisjunctiveLicenseBase [ 'url' ]
84
88
}
@@ -94,7 +98,10 @@ export class NamedLicense extends DisjunctiveLicenseBase {
94
98
}
95
99
96
100
compare ( other : NamedLicense ) : number {
97
- return this . name . localeCompare ( other . name )
101
+ /* eslint-disable @typescript-eslint/strict-boolean-expressions -- run compares in weighted order */
102
+ return this . name . localeCompare ( other . name ) ||
103
+ this . bomRef . compare ( other . bomRef )
104
+ /* eslint-enable @typescript-eslint/strict-boolean-expressions */
98
105
}
99
106
}
100
107
@@ -134,7 +141,10 @@ export class SpdxLicense extends DisjunctiveLicenseBase {
134
141
}
135
142
136
143
compare ( other : SpdxLicense ) : number {
137
- return this . #id. localeCompare ( other . #id)
144
+ /* eslint-disable @typescript-eslint/strict-boolean-expressions -- run compares in weighted order */
145
+ return this . #id. localeCompare ( other . #id) ||
146
+ this . bomRef . compare ( other . bomRef )
147
+ /* eslint-enable @typescript-eslint/strict-boolean-expressions */
138
148
}
139
149
}
140
150
0 commit comments