diff --git a/utils.js b/utils.js index 94527bfe5..9cef5fc35 100644 --- a/utils.js +++ b/utils.js @@ -221,6 +221,8 @@ export function getLicenses(pkg, format = "xml") { licenseContent.name = "CUSTOM"; } licenseContent.url = l; + } else if (l.includes(" ") || l.includes("(")) { + licenseContent.expression = l; } else { licenseContent.name = l; } @@ -234,7 +236,9 @@ export function getLicenses(pkg, format = "xml") { } return licenseContent; }) - .map((l) => ({ license: l })); + .map((l) => + l.expression ? { expression: l.expression } : { license: l } + ); } return undefined; } diff --git a/utils.test.js b/utils.test.js index 93b04f5f8..8cd8374f4 100644 --- a/utils.test.js +++ b/utils.test.js @@ -1591,6 +1591,16 @@ test("get licenses", () => { } } ]); + + let inputLicense = "(MIT or Apache-2.0)"; + licenses = getLicenses({ + license: inputLicense + }); + expect(licenses).toEqual([ + { + expression: inputLicense + } + ]); }); test("parsePkgLock v1", async () => {