@@ -12,7 +12,7 @@ import parse from 'spdx-expression-parse'
1212// accepts a pair of well-formed SPDX expressions. the
1313// candidate is tested against the constraint
1414export function satisfies ( candidateExpr : string , allowList : string [ ] ) : boolean {
15- candidateExpr = removeInvalidSPDX ( candidateExpr )
15+ candidateExpr = cleanInvalidSPDX ( candidateExpr )
1616 try {
1717 return spdxSatisfies ( candidateExpr , allowList )
1818 } catch ( _ ) {
@@ -25,7 +25,7 @@ export function satisfiesAny(
2525 candidateExpr : string ,
2626 licenses : string [ ]
2727) : boolean {
28- candidateExpr = removeInvalidSPDX ( candidateExpr )
28+ candidateExpr = cleanInvalidSPDX ( candidateExpr )
2929 try {
3030 return spdxlib . satisfiesAny ( candidateExpr , licenses )
3131 } catch ( _ ) {
@@ -38,7 +38,7 @@ export function satisfiesAll(
3838 candidateExpr : string ,
3939 licenses : string [ ]
4040) : boolean {
41- candidateExpr = removeInvalidSPDX ( candidateExpr )
41+ candidateExpr = cleanInvalidSPDX ( candidateExpr )
4242 try {
4343 return spdxlib . satisfiesAll ( candidateExpr , licenses )
4444 } catch ( _ ) {
@@ -48,7 +48,7 @@ export function satisfiesAll(
4848
4949// accepts any SPDX expression
5050export function isValid ( spdxExpr : string ) : boolean {
51- spdxExpr = removeInvalidSPDX ( spdxExpr )
51+ spdxExpr = cleanInvalidSPDX ( spdxExpr )
5252 try {
5353 parse ( spdxExpr )
5454 return true
@@ -57,10 +57,10 @@ export function isValid(spdxExpr: string): boolean {
5757 }
5858}
5959
60- const replaceOtherRegex = / (?< ! [ \w - ] ) O T H E R (? ! [ \w - ] ) /
60+ const replaceOtherRegex = / (?< ! [ \w - ] ) O T H E R (? ! [ \w - ] ) / g
6161
6262// adjusts license expressions to not include the invalid `OTHER`
6363// which ClearlyDefined adds to license strings
64- export function removeInvalidSPDX ( spdxExpr : string ) : string {
64+ export function cleanInvalidSPDX ( spdxExpr : string ) : string {
6565 return spdxExpr . replace ( replaceOtherRegex , 'LicenseRef-clearlydefined-OTHER' )
6666}
0 commit comments