jskos-tools
Advanced tools
Comparing version 1.0.21 to 1.0.22
@@ -119,9 +119,4 @@ const _ = require("./utils") | ||
/** | ||
* Returns all possible URIs for a JSKOS object. Takes into consideration both the uri and identifier properties, as well as different variants of those identifiers. | ||
* Returns all possible URIs for a JSKOS object. Takes into consideration both the uri and identifier properties. | ||
* | ||
* Variants: | ||
* - http vs. https | ||
* - with trailing slash vs. without trailing slash | ||
* - /en/ vs. /de/ | ||
* | ||
* @memberof module:jskos-tools | ||
@@ -132,8 +127,3 @@ * @param {object} object | ||
if (!object) return [] | ||
let uris = (object.uri ? [object.uri] : []).concat(object.identifier || []) | ||
// Generate several variants of URIs to work around inconsistencies | ||
uris = uris.concat(uris.map(uri => uri.startsWith("https") ? uri.replace("https", "http") : uri.replace("http", "https"))) | ||
uris = uris.concat(uris.map(uri => uri.endsWith("/") ? uri.substring(0, uri.length - 1) : uri + "/")) | ||
uris = uris.concat(uris.map(uri => uri.indexOf("/en/") != -1 ? uri.replace("/en/", "/de/") : uri.replace("/de/", "/en/"))) | ||
return [...new Set(uris)] | ||
return (object.uri ? [object.uri] : []).concat(object.identifier || []) | ||
} | ||
@@ -154,4 +144,5 @@ | ||
// Compare URIs for objects. | ||
let object1uris = getAllUris(object1) | ||
let object2uris = getAllUris(object2) | ||
const replaceUri = uri => uri.replace("http://").replace("https://") | ||
let object1uris = getAllUris(object1).map(replaceUri) | ||
let object2uris = getAllUris(object2).map(replaceUri) | ||
if (_.intersection(object1uris, object2uris).length > 0) { | ||
@@ -158,0 +149,0 @@ return true |
{ | ||
"name": "jskos-tools", | ||
"version": "1.0.21", | ||
"version": "1.0.22", | ||
"description": "Tools for working with the JSKOS data format.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/gbv/jskos-tools", |
Sorry, the diff of this file is too big to display
142177
3706