Socket
Socket
Sign inDemoInstall

pg-connection-string

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-connection-string - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

10

index.js

@@ -39,3 +39,11 @@ 'use strict';

config.host = result.hostname;
config.database = result.pathname ? decodeURI(result.pathname.slice(1)) : null;
// result.pathname is not always guaranteed to have a '/' prefix (e.g. relative urls)
// only strip the slash if it is present.
var pathname = result.pathname;
if (pathname && pathname.charAt(0) === '/') {
pathname = result.pathname.slice(1) || null;
}
config.database = pathname && decodeURI(pathname);
var auth = (result.auth || ':').split(':');

@@ -42,0 +50,0 @@ config.user = auth[0];

2

package.json
{
"name": "pg-connection-string",
"version": "0.1.1",
"version": "0.1.2",
"description": "Functions for dealing with a PostgresSQL connection string",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -90,1 +90,24 @@ 'use strict';

});
test('relative url sets database', function(t){
var relative = 'different_db_on_default_host';
var subject = parse(relative);
t.equal(subject.database, 'different_db_on_default_host');
t.end();
});
test('no pathname returns null database', function (t) {
var subject = parse('pg://myhost');
t.equal(subject.host, 'myhost');
t.type(subject.database, 'null');
t.end();
});
test('pathname of "/" returns null database', function (t) {
var subject = parse('pg://myhost/');
t.equal(subject.host, 'myhost');
t.type(subject.database, 'null');
t.end();
});
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