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

oconf

Package Overview
Dependencies
Maintainers
5
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oconf - npm Package Compare versions

Comparing version 5.0.0 to 5.1.0

16

lib/index.js

@@ -41,4 +41,7 @@ /*

var hashPublicSuffixedKeys = [];
Object.keys(obj).forEach(function (key) {
if (key !== '#public') {
if (/.+#public$/.test(key)) {
hashPublicSuffixedKeys.push(key);
} else if (key !== '#public') {
// Have to extract public and non-public keys separately, otherwise we lose information

@@ -53,2 +56,13 @@ var resolvedPublic = resolvePublic(obj[key], false, true);

});
if (hashPublicSuffixedKeys.length > 0) {
obj['#public'] = obj['#public'] || {};
hashPublicSuffixedKeys.forEach(function (hashPublicSuffixedKey) {
var keyWithoutSuffix = hashPublicSuffixedKey.replace(/#public$/, '');
if (keyWithoutSuffix in obj['#public']) {
throw new Error(hashPublicSuffixedKey + ' clashes with ' + keyWithoutSuffix + ' inside #public block');
}
obj['#public'][keyWithoutSuffix] = obj[hashPublicSuffixedKey];
delete obj[hashPublicSuffixedKey];
});
}

@@ -55,0 +69,0 @@ if (typeof obj['#public'] !== 'undefined') {

5

package.json

@@ -5,3 +5,3 @@ {

"description": "Configuration",
"version": "5.0.0",
"version": "5.1.0",
"repository": {

@@ -51,4 +51,5 @@ "type": "git",

"mocha": "*",
"unexpected": "10.8.1"
"unexpected": "10.8.1",
"unexpected-fs": "2.1.3"
}
}
/*global describe, it, before*/
var expect = require('unexpected');
var expect = require('unexpected').clone().use(require('unexpected-fs'));
var oconf = require('../../lib/index');

@@ -390,2 +390,54 @@

});
expect.addAssertion('<object> to resolve to <object>', function (expect, subject, value) {
return expect(function () {
expect(oconf.load('/testdata/config.cjson'), 'to equal', value);
}, 'with fs mocked out', {
'/testdata': {
'config.cjson': JSON.stringify(subject)
}
}, 'not to error');
});
expect.addAssertion('<object> to result in error <any?>', function (expect, subject, value) {
return expect(function () {
expect(oconf.load('/testdata/config.cjson'), 'to equal', value);
}, 'with fs mocked out', {
'/testdata': {
'config.cjson': JSON.stringify(subject)
}
}, 'to error', value);
});
describe('with a #public-suffixed key', function () {
it('treats the key as if contained inside a #public block', function () {
expect({
foo: {
'bar#public': 123,
quux: 456
}
}, 'to resolve to', {
foo: {
bar: 123,
quux: 456
},
'#public': {
foo: {
bar: 123
}
}
});
});
it('complains if a #public-suffixed key shadows an entry inside a #public block', function () {
expect({
foo: {
'#public': {
foo: 123
},
'foo#public': 456
}
}, 'to result in error', new Error('foo#public clashes with foo inside #public block'));
});
});
});
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