myst-frontmatter
Advanced tools
Comparing version 1.7.4 to 1.7.5
@@ -88,2 +88,3 @@ import { validationWarning, defined, incrementOptions, validateObjectKeys, validateString, validateUrl, validateBoolean, } from 'simple-validators'; | ||
export function validateLicense(input, opts) { | ||
var _a; | ||
if (typeof input === 'string') { | ||
@@ -93,3 +94,4 @@ const value = validateString(input, opts); | ||
return undefined; | ||
const valueSpdx = correctLicense(value); | ||
// Do not try to coerce long values into SPDX licenses | ||
const valueSpdx = value.length < 15 ? correctLicense(value) : undefined; | ||
if (URL_ID_LOOKUP[cleanUrl(value)]) { | ||
@@ -133,3 +135,13 @@ input = { id: URL_ID_LOOKUP[cleanUrl(value)] }; | ||
else { | ||
validationWarning(`no license ID - using a SPDX license ID is recommended, see https://spdx.org/licenses/`, opts); | ||
if (value.url) { | ||
const url = (_a = validateUrl(value.url, { property: '', messages: {} })) !== null && _a !== void 0 ? _a : ''; | ||
const idFromUrl = URL_ID_LOOKUP[cleanUrl(url)]; | ||
if (idFromUrl) { | ||
output.id = idFromUrl; | ||
value.url = ID_LICENSE_LOOKUP[idFromUrl].url; | ||
} | ||
} | ||
if (!output.id) { | ||
validationWarning(`no license ID - using a SPDX license ID is recommended, see https://spdx.org/licenses/`, opts); | ||
} | ||
} | ||
@@ -136,0 +148,0 @@ const expected = output.id ? ID_LICENSE_LOOKUP[output.id] : undefined; |
{ | ||
"name": "myst-frontmatter", | ||
"version": "1.7.4", | ||
"version": "1.7.5", | ||
"sideEffects": false, | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
237397
5995