@jsenv/url-meta
Advanced tools
Comparing version 5.1.0 to 5.1.1
@@ -436,10 +436,23 @@ 'use strict'; | ||
var assertSpecifierMetaMap = function assertSpecifierMetaMap(value) { | ||
var checkComposition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
if (!isPlainObject(value)) { | ||
throw new TypeError("specifierMetaMap must be a plain object, got ".concat(value)); | ||
} // we could ensure it's key/value pair of url like key/object or null values | ||
} | ||
if (checkComposition) { | ||
var plainObject = value; | ||
Object.keys(plainObject).forEach(function (key) { | ||
assertUrlLike(key, "specifierMetaMap key"); | ||
var value = plainObject[key]; | ||
if (value !== null && !isPlainObject(value)) { | ||
throw new TypeError("specifierMetaMap value must be a plain object or null, got ".concat(value, " under key ").concat(key)); | ||
} | ||
}); | ||
} | ||
}; | ||
var normalizeSpecifierMetaMap = function normalizeSpecifierMetaMap(specifierMetaMap, url) { | ||
assertSpecifierMetaMap(specifierMetaMap); | ||
assertSpecifierMetaMap(specifierMetaMap, false); | ||
assertUrlLike(url, "url"); | ||
@@ -446,0 +459,0 @@ |
{ | ||
"name": "@jsenv/url-meta", | ||
"version": "5.1.0", | ||
"version": "5.1.1", | ||
"description": "Associate data to urls using patterns.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -58,3 +58,3 @@ # url-meta | ||
```console | ||
npm install @jsenv/url-meta@5.1.0 | ||
npm install @jsenv/url-meta@5.1.1 | ||
``` | ||
@@ -61,0 +61,0 @@ |
import { isPlainObject } from "./isPlainObject.js" | ||
import { assertUrlLike } from "./assertUrlLike.js" | ||
export const assertSpecifierMetaMap = (value) => { | ||
export const assertSpecifierMetaMap = (value, checkComposition = true) => { | ||
if (!isPlainObject(value)) { | ||
throw new TypeError(`specifierMetaMap must be a plain object, got ${value}`) | ||
} | ||
// we could ensure it's key/value pair of url like key/object or null values | ||
if (checkComposition) { | ||
const plainObject = value | ||
Object.keys(plainObject).forEach((key) => { | ||
assertUrlLike(key, "specifierMetaMap key") | ||
const value = plainObject[key] | ||
if (value !== null && !isPlainObject(value)) { | ||
throw new TypeError( | ||
`specifierMetaMap value must be a plain object or null, got ${value} under key ${key}`, | ||
) | ||
} | ||
}) | ||
} | ||
} |
@@ -5,3 +5,3 @@ import { assertSpecifierMetaMap } from "./internal/assertSpecifierMetaMap.js" | ||
export const normalizeSpecifierMetaMap = (specifierMetaMap, url, ...rest) => { | ||
assertSpecifierMetaMap(specifierMetaMap) | ||
assertSpecifierMetaMap(specifierMetaMap, false) | ||
assertUrlLike(url, "url") | ||
@@ -8,0 +8,0 @@ if (rest.length) { |
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
54629
830