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

pg-hstore

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-hstore - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

11

lib/index.js

@@ -46,6 +46,7 @@ (function () {

parse: function(value, callback) {
parse: function(string, callback) {
var result = {},
r = /(["])(?:\\\1|.)*?\1/g,
matches = value.match(r),
//using [\s\S] to match any character, including line feed and carriage return,
r = /(["])(?:\\\1|[\s\S])*?\1|NULL/g,
matches = string.match(r),
i,

@@ -61,3 +62,5 @@ l,

for (i = 0, l = matches.length; i < l; i+= 2) {
result[clean(matches[i])] = clean(matches[i + 1]);
var key = clean(matches[i]);
var value = matches[i + 1];
result[key] = value=="NULL"?null:clean(value);
}

@@ -64,0 +67,0 @@ if (!callback || callback === null) return result;

@@ -7,3 +7,3 @@ {

"keywords": ["pg", "postgres", "hstore"],
"version": "2.0.0",
"version": "2.1.0",
"main": "lib/index.js",

@@ -10,0 +10,0 @@ "homepage": "https://github.com/scarney81/pg-hstore",

@@ -6,2 +6,3 @@ /*globals it, describe, beforeEach */

var should = require('should'),
assert= require('assert'),
HStore = require('../lib/index.js'),

@@ -61,3 +62,25 @@ hstore;

});
it('should hstore parse a string with NULL values', function (done) {
var source = '"foo"=>"oof","bar"=>NULL,"baz"=>"zab"';
hstore.parse(source, function (target) {
should.exist(target);
target.foo.should.equal('oof');
assert.equal(target.bar, null);
target.baz.should.equal('zab');
done();
});
});
it('should hstore parse a string with \n values', function (done) {
var source = '"foo"=>"o\rof","bar"=>NULL,"baz"=>"z\nab"';
hstore.parse(source, function (target) {
should.exist(target);
target.foo.should.equal('o\rof');
assert.equal(target.bar, null);
target.baz.should.equal('z\nab');
done();
});
});
});
})();
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