Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

deref

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deref - npm Package Compare versions

Comparing version 0.2.6 to 0.2.7

20

lib/index.js

@@ -25,18 +25,16 @@ 'use strict';

if (typeof ref.id === 'string') {
var base = $.getDocumentURI(ref.id) || ref.id;
var id = $.resolveURL(fakeroot, ref.id).replace(/\/#?$/, '');
if (/#([^\/]+)/.test(ref.id)) {
base = ref.id.split('#')[1];
if (id.indexOf('#') > -1) {
var parts = id.split('#');
if (!$ref.refs[base]) {
$ref.refs[base] = {
$ref: ref.id
};
if (parts[1].charAt() === '/') {
id = parts[0];
} else {
id = parts[1] || parts[0];
}
base = ref.id;
}
if (!$ref.refs[base]) {
$ref.refs[base] = ref;
if (!$ref.refs[id]) {
$ref.refs[id] = ref;
}

@@ -43,0 +41,0 @@ }

@@ -26,3 +26,5 @@ 'use strict';

if (!target) {
if (target) {
target = id.indexOf('#/') > -1 ? get(target, id) : target;
} else {
for (var key in refs) {

@@ -36,6 +38,2 @@ if ($.resolveURL(refs[key].id, id) === refs[key].id) {

if (id.indexOf('#/') > -1) {
target = get(target, id);
}
if (!target) {

@@ -42,0 +40,0 @@ throw new Error('Reference not found: ' + id);

@@ -7,13 +7,22 @@ 'use strict';

var SCHEMA_URI = 'http://json-schema.org/schema#';
var SCHEMA_URI = [
'http://json-schema.org/schema#',
'http://json-schema.org/draft-04/schema#'
];
function expand(obj, parent, callback) {
if (obj) {
if (typeof obj.id === 'string') {
parent = obj.id = $.resolveURL(parent, obj.id);
var id = typeof obj.id === 'string' ? obj.id : '#';
if (!$.isURL(id)) {
id = $.resolveURL(parent === id ? null : parent, id);
}
if (obj.$ref) {
obj.$ref = $.resolveURL(parent, obj.$ref);
if (typeof obj.$ref === 'string' && !$.isURL(obj.$ref)) {
obj.$ref = $.resolveURL(id, obj.$ref);
}
if (typeof obj.id === 'string') {
obj.id = parent = id;
}
}

@@ -41,10 +50,16 @@

var copy = cloneObj(schema),
base = $.resolveURL(copy.$schema || SCHEMA_URI, fakeroot || '');
var base = fakeroot || '',
copy = cloneObj(schema);
copy.id = $.resolveURL(base, copy.id || '#');
if (copy.$schema) {
base = $.resolveURL(copy.$schema, base);
}
expand(copy, copy.id, push);
if (base && SCHEMA_URI.indexOf(base) === -1) {
throw new Error('Unsupported schema version (v4 only)');
}
expand(copy, $.resolveURL(base, copy.id || '#'), push);
return copy;
};

@@ -18,4 +18,10 @@ 'use strict';

if (fixed && expand) {
var id = typeof fixed.id === 'string' ? fixed.id : '#';
obj = fixed;
if (obj.$ref !== id) {
return clone(fixed, refs, true, expand);
}
delete obj.$ref;

@@ -22,0 +28,0 @@ }

@@ -78,2 +78,4 @@ 'use strict';

function resolveURL(base, href) {
base = base || 'http://json-schema.org/schema#';
href = parseURI(href, base);

@@ -80,0 +82,0 @@ base = parseURI(base);

{
"name": "deref",
"version": "0.2.6",
"version": "0.2.7",
"description": "JSON-Schema $ref resolution",

@@ -11,10 +11,10 @@ "main": "lib/index.js",

"devDependencies": {
"clone": "^0.1.18",
"glob": "^4.2.1",
"clone": "^0.1.19",
"glob": "^4.3.5",
"grunt": "^0.4.5",
"grunt-parts": "^0.3.0",
"grunt-parts": "^0.3.1",
"jayschema": "^0.3.1",
"tv4": "^1.1.4",
"z-schema": "^3.1.3"
"tv4": "^1.1.9",
"z-schema": "^3.3.1"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc