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.1 to 0.2.2

29

lib/util/resolve-schema.js
'use strict';
var $ = require('./uri-helpers'),
jsptr = require('jsonpointer');
var $ = require('./uri-helpers');
function get(obj, path) {
var hash = path.split('#')[1];
if (hash.charAt() === '/') {
var parts = hash.replace(/~1/g, '/').replace(/~0/g, '~').split('/').slice(1);
while (parts.length) {
var key = parts.shift();
if (typeof obj[key] === 'undefined') {
throw new Error('Reference not found: ' + path);
}
obj = obj[key];
}
return obj;
}
}
function clone(obj, refs, child, expand) {

@@ -20,8 +39,4 @@ var copy = {};

if (obj.$ref.indexOf('#') > -1) {
var hash = obj.$ref.split('#')[1];
fixed = get(refs[uri], obj.$ref) || fixed;
if (hash.charAt() === '/') {
fixed = jsptr.get(refs[uri], hash);
}
// TODO: otherwise? (i.e. http://example.com/schema#someId)

@@ -28,0 +43,0 @@ // console.log('REF (find by?)', obj.$ref, typeof refs[uri], uri === obj.$ref);

{
"name": "deref",
"version": "0.2.1",
"version": "0.2.2",
"description": "JSON-Schema $ref resolution",

@@ -17,6 +17,3 @@ "main": "lib/index.js",

"z-schema": "^3.1.3"
},
"dependencies": {
"jsonpointer": "^1.1.0"
}
}
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