myst-frontmatter
Advanced tools
Comparing version
@@ -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
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
237397
0.21%5995
0.2%