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

jsen

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsen - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

21

lib/resolver.js

@@ -77,2 +77,16 @@ 'use strict';

function refFromId(obj, ref) {
if (obj && typeof obj === 'object') {
if (obj.id === ref) {
return obj;
}
return Object.keys(obj).reduce(function (resolved, key) {
return resolved || refFromId(obj[key], ref);
}, undefined);
}
return undefined;
}
function SchemaResolver(rootSchema) {

@@ -97,3 +111,8 @@ this.rootSchema = rootSchema;

}
else {
if (!dest) {
dest = refFromId(root, ref);
}
if (!dest) {
path = refToPath(ref);

@@ -100,0 +119,0 @@

2

package.json
{
"name": "jsen",
"version": "0.1.1",
"version": "0.1.2",
"description": "JSON-Schema validator built for speed.",

@@ -5,0 +5,0 @@ "author": "Veli Pehlivanov <bugventure@gmail.com>",

@@ -36,2 +36,3 @@ JSEN

- [Changelog](#changelog)
- [v0.1.2](#v012)
- [v0.1.1](#v011)

@@ -506,2 +507,6 @@ - [v0.1.0](#v010)

### v0.1.2
* Fix cannot dereference schema when ids change resolution scope (#14)
### v0.1.1

@@ -508,0 +513,0 @@

@@ -35,2 +35,41 @@ 'use strict';

});
it('Fix cannot dereference schema when ids change resolution scope (#14)', function () {
var schema = {
$ref: '#child',
definitions: {
child: {
id: '#child',
type: 'string'
}
}
},
validate;
assert.doesNotThrow(function () {
validate = jsen(schema);
});
assert(validate('abc'));
assert(!validate(123));
schema = {
$ref: '#child/definitions/subchild',
definitions: {
child: {
id: '#child',
definitions: {
subchild: {
type: 'number'
}
}
}
}
};
assert.throws(function () {
// cannot dereference a URI, part of which is an ID
validate = jsen(schema);
});
});
});
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