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

mongo-express

Package Overview
Dependencies
Maintainers
1
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongo-express - npm Package Compare versions

Comparing version 0.17.3 to 0.17.4

json.js

68

bson.js
var mongodb = require('mongodb');
var vm = require('vm');
var json = require('./json');

@@ -56,67 +57,6 @@

//Function for converting BSON docs to string representation
//Convert BSON documents to string
exports.toString = function(doc) {
//Let JSON.stringify do most of the hard work
//Then use replacer function to replace the BSON data
var replacer = function(obj) {
var stack = new Array();
return function(key, value) {
if (key == '') {
return value;
}
//Use a stack to recursively replace BSON values with BSON functions
//Needed to parse documents with >1 depth
var o = stack.pop();
if (o == undefined) {
o = obj[key];
} else {
o = o[key];
}
//Replace data types with associated functions
//JSON automatically converts values to strings
//$$rep$$ placeholder is used to remove extra quotation marks at the end
//$$replace$$ is placeholder to add unescaped quotation marks
if (o instanceof mongodb.ObjectID) {
return '$$rep$$ObjectId($$replace$$' + value + '$$replace$$)$$rep$$';
} else if (o instanceof mongodb.Timestamp) {
return '$$rep$$Timestamp(' + o.high_ + ', ' + o.low_ + ')$$rep$$';
} else if (o instanceof Date) {
return '$$rep$$ISODate($$replace$$' + value + '$$replace$$)$$rep$$';
} else if (o instanceof mongodb.DBRef) {
if (o.db == '') {
return '$$rep$$DBRef($$replace$$' + o.namespace + '$$replace$$, $$replace$$' + o.oid + '$$replace$$)$$rep$$';
} else {
return '$$rep$$DBRef($$replace$$' + o.namespace + '$$replace$$, $$replace$$' + o.oid + '$$replace$$, $$replace$$' + o.db + '$$replace$$)$$rep$$';
}
} else if (o instanceof mongodb.Code) {
return '$$rep$$Code($$replace$$' + o.code + '$$replace$$)$$rep$$';
} else if (o instanceof mongodb.MinKey) {
return '$$rep$$MinKey()$$rep$$';
} else if (o instanceof mongodb.MaxKey) {
return '$$rep$$MaxKey()$$rep$$';
} else if (o instanceof mongodb.Symbol) {
return '$$rep$$Symbol($$replace$$' + value + '$$replace$$)$$rep$$';
} else if (typeof o == 'object') {
//Add current depth object to stack
for (var i in o) {
stack.push(o);
}
return value;
} else {
return value;
}
};
};
var newDoc = JSON.stringify(doc, replacer(doc), ' ');
newDoc = newDoc.replace(/"\$\$rep\$\$/gi, "");
newDoc = newDoc.replace(/\$\$rep\$\$"/gi, "");
newDoc = newDoc.replace(/\$\$replace\$\$/gi, "\"");
return newDoc;
//Use custom json stringify function from json.js
return json.stringify(doc, null, ' ');
};

@@ -0,1 +1,7 @@

0.17.4
------
* Removed hacky BSON->string conversion function
* Replaced it with a modified JSON.stringify function
0.17.3

@@ -2,0 +8,0 @@ ------

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

"description": "Web-based admin interface for MongoDB",
"version": "0.17.3",
"version": "0.17.4",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

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