Match license identifiers case-insensitively
MODIFY
internal/codec-spdx-license/index.ts
internal/codec-spdx-license/index.ts
@@ -23,7 +23,7 @@ const idToLicense: Map<string, License> = new Map();
const licenseNames: Array<string> = [];
for (const license of data.licenses) {
licenseNames.push(license.licenseId);
- idToLicense.set(license.licenseId, license);
+ idToLicense.set(license.licenseId.toLowerCase(), license);
}
export {licenseNames};
@@ -31,7 +31,7 @@ export {licenseNames};
export {ExpressionNode as SPDXExpressionNode} from "./parse";
export function getSPDXLicense(licenseId: string): undefined | License {
- return idToLicense.get(licenseId);
+ return idToLicense.get(licenseId.toLowerCase());
}
export {default as parseSPDXLicense} from "./parse";

MODIFY
internal/codec-spdx-license/parse.ts
internal/codec-spdx-license/parse.ts
@@ -170,7 +170,7 @@ const createSPDXLicenseParser = createParser((ParserCore) =>
return {
type: "License",
loc: this.finishLoc(startPos),
- id,
+ id: licenseInfo.licenseId,
exception,
plus,
};

MODIFY
internal/diagnostics/descriptions/parsers/spdx.ts
internal/diagnostics/descriptions/parsers/spdx.ts
@@ -7,7 +7,7 @@ export const spdx = createDiagnosticsCategory({
UNKNOWN_LICENSE: (id: string, knownLicenses: Array<string>) => ({
message: markup`Unknown license <emphasis>${id}</emphasis>`,
advice: [
- ...buildSuggestionAdvice(id, knownLicenses),
+ ...buildSuggestionAdvice(id, knownLicenses, {ignoreCase: true}),
{
type: "log",
category: "info",

Match license identifiers case-insensitively (#1030)