mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-12 02:42:48 +00:00
updated bunch of file paths and changed the way posts are loaded
This commit is contained in:
2
node_modules/muri/.npmignore
generated
vendored
Normal file
2
node_modules/muri/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.sw*
|
||||
node_modules/
|
||||
4
node_modules/muri/.travis.yml
generated
vendored
Normal file
4
node_modules/muri/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.6
|
||||
- 0.8
|
||||
52
node_modules/muri/History.md
generated
vendored
Normal file
52
node_modules/muri/History.md
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
1.0.0 / 2014-10-18
|
||||
==================
|
||||
|
||||
* fixed; compatibility w/ strict mode #4 [vkarpov15](https://github.com/vkarpov15)
|
||||
|
||||
0.3.1 / 2013-02-17
|
||||
==================
|
||||
|
||||
* fixed; allow '#' in username and password #3
|
||||
|
||||
0.3.0 / 2013-01-14
|
||||
==================
|
||||
|
||||
* fixed; default db logic #2
|
||||
|
||||
0.2.0 / 2013-01-09
|
||||
==================
|
||||
|
||||
* changed; default db is now 'test'
|
||||
|
||||
0.1.0 / 2012-12-18
|
||||
==================
|
||||
|
||||
* changed; include .sock in UDS
|
||||
|
||||
0.0.5 / 2012-12-18
|
||||
==================
|
||||
|
||||
* fixed; unix domain sockets used with db names
|
||||
|
||||
0.0.4 / 2012-12-01
|
||||
==================
|
||||
|
||||
* handle multple specified protocols
|
||||
|
||||
0.0.3 / 2012-11-29
|
||||
==================
|
||||
|
||||
* validate mongodb:///db
|
||||
* more detailed error message
|
||||
|
||||
0.0.2 / 2012-11-02
|
||||
==================
|
||||
|
||||
* add readPreferenceTags support
|
||||
* add unix domain support
|
||||
|
||||
0.0.1 / 2012-11-01
|
||||
==================
|
||||
|
||||
* initial release
|
||||
22
node_modules/muri/LICENSE
generated
vendored
Normal file
22
node_modules/muri/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012 [Aaron Heckmann](aaron.heckmann+github@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
5
node_modules/muri/Makefile
generated
vendored
Normal file
5
node_modules/muri/Makefile
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
test:
|
||||
@node_modules/mocha/bin/mocha $(T)
|
||||
|
||||
.PHONY: test
|
||||
46
node_modules/muri/README.md
generated
vendored
Normal file
46
node_modules/muri/README.md
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
#Meet Muri!
|
||||
|
||||
Muri is your friendly neighborhood [MongoDB URI](http://www.mongodb.org/display/DOCS/Connections) parser for Node.js.
|
||||
|
||||
|
||||
###Install
|
||||
|
||||
$ npm install muri
|
||||
|
||||
###Use
|
||||
|
||||
```js
|
||||
var muri = require('muri');
|
||||
var o = muri('mongodb://user:pass@local,remote:27018,japan:27019/neatdb?replicaSet=myreplset&journal=true&w=2&wtimeoutMS=50');
|
||||
|
||||
console.log(o);
|
||||
|
||||
{ hosts: [ { host: 'local', port: 27017 },
|
||||
{ host: 'remote', port: 27018 },
|
||||
{ host: 'japan', port: 27019 } ],
|
||||
db: 'neatdb',
|
||||
options: {
|
||||
replicaSet: 'myreplset',
|
||||
journal: true,
|
||||
w: 2,
|
||||
wtimeoutMS: 50
|
||||
},
|
||||
auth: {
|
||||
user: 'user',
|
||||
pass: 'pass'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Details
|
||||
|
||||
The returned object contains the following properties:
|
||||
|
||||
- db: the name of the database. defaults to "admin" if not specified
|
||||
- auth: if auth is specified, this object will exist `{ user: 'username', pass: 'password' }`
|
||||
- hosts: array of host/port objects, one for each specified `[{ host: 'local', port: 27107 }, { host: '..', port: port }]`
|
||||
- if a port is not specified for a given host, the default port (27017) is used
|
||||
- if a unix domain socket is passed, host/port will be undefined and `ipc` will be set to the value specified `[{ ipc: '/tmp/mongodb-27017' }]`
|
||||
- options: this is a hash of all options specified in the querystring
|
||||
|
||||
[LICENSE](https://github.com/aheckmann/muri/blob/master/LICENSE)
|
||||
1
node_modules/muri/index.js
generated
vendored
Normal file
1
node_modules/muri/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = exports = require('./lib');
|
||||
235
node_modules/muri/lib/index.js
generated
vendored
Normal file
235
node_modules/muri/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
// muri
|
||||
|
||||
/**
|
||||
* MongoDB URI parser as described here:
|
||||
* http://www.mongodb.org/display/DOCS/Connections
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
var qs = require('querystring');
|
||||
|
||||
/**
|
||||
* Defaults
|
||||
*/
|
||||
|
||||
var DEFAULT_PORT = 27017;
|
||||
var DEFAULT_DB = 'test';
|
||||
var ADMIN_DB = 'admin';
|
||||
|
||||
/**
|
||||
* Muri
|
||||
*/
|
||||
|
||||
module.exports = exports = function muri (str) {
|
||||
if (!/^mongodb:\/\//.test(str)) {
|
||||
throw new Error('Invalid mongodb uri. Must begin with "mongodb://"'
|
||||
+ '\n Received: ' + str);
|
||||
}
|
||||
|
||||
var ret = {
|
||||
hosts: []
|
||||
, db: DEFAULT_DB
|
||||
, options: {}
|
||||
}
|
||||
|
||||
var match = /^mongodb:\/\/([^?]+)(\??.*)$/.exec(str);
|
||||
if (!match || '/' == match[1]) {
|
||||
throw new Error('Invalid mongodb uri. Missing hostname');
|
||||
}
|
||||
|
||||
var uris = match[1];
|
||||
var path = match[2];
|
||||
var db;
|
||||
|
||||
uris.split(',').forEach(function (uri) {
|
||||
var o = parse(uri);
|
||||
|
||||
if (o.host) {
|
||||
ret.hosts.push({
|
||||
host: o.host
|
||||
, port: parseInt(o.port, 10)
|
||||
})
|
||||
|
||||
if (!db && o.db) {
|
||||
db = o.db;
|
||||
}
|
||||
} else if (o.ipc) {
|
||||
ret.hosts.push({ ipc: o.ipc });
|
||||
}
|
||||
|
||||
if (o.auth) {
|
||||
ret.auth = {
|
||||
user: o.auth.user
|
||||
, pass: o.auth.pass
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (!ret.hosts.length) {
|
||||
throw new Error('Invalid mongodb uri. Missing hostname');
|
||||
}
|
||||
|
||||
var parts = path.split('?');
|
||||
|
||||
if (!db) {
|
||||
if (parts[0]) {
|
||||
db = parts[0].replace(/^\//, '');
|
||||
} else {
|
||||
// deal with ipc formats
|
||||
db = /\/([^\.]+)$/.exec(match[1]);
|
||||
if (db && db[1]) {
|
||||
db = db[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (db) {
|
||||
ret.db = db;
|
||||
} else if (ret.auth) {
|
||||
ret.db = ADMIN_DB;
|
||||
}
|
||||
|
||||
if (parts[1]) {
|
||||
ret.options = options(parts[1]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse str into key/val pairs casting values appropriately.
|
||||
*/
|
||||
|
||||
function options (str) {
|
||||
var sep = /;/.test(str)
|
||||
? ';'
|
||||
: '&';
|
||||
|
||||
var ret = qs.parse(str, sep);
|
||||
|
||||
Object.keys(ret).forEach(function (key) {
|
||||
var val = ret[key];
|
||||
if ('readPreferenceTags' == key) {
|
||||
val = readPref(val);
|
||||
if (val) {
|
||||
ret[key] = Array.isArray(val)
|
||||
? val
|
||||
: [val];
|
||||
}
|
||||
} else {
|
||||
ret[key] = format(val);
|
||||
}
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function format (val) {
|
||||
var num;
|
||||
|
||||
if ('true' == val) {
|
||||
return true;
|
||||
} else if ('false' == val) {
|
||||
return false;
|
||||
} else {
|
||||
num = parseInt(val, 10);
|
||||
if (!isNaN(num)) {
|
||||
return num;
|
||||
}
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
function readPref (val) {
|
||||
var ret;
|
||||
|
||||
if (Array.isArray(val)) {
|
||||
ret = val.map(readPref).filter(Boolean);
|
||||
return ret.length
|
||||
? ret
|
||||
: undefined
|
||||
}
|
||||
|
||||
var pair = val.split(',');
|
||||
var hasKeys;
|
||||
ret = {};
|
||||
|
||||
pair.forEach(function (kv) {
|
||||
kv = (kv || '').trim();
|
||||
if (!kv) return;
|
||||
hasKeys = true;
|
||||
var split = kv.split(':');
|
||||
ret[split[0]] = format(split[1]);
|
||||
});
|
||||
|
||||
return hasKeys && ret;
|
||||
}
|
||||
|
||||
var ipcRgx = /\.sock/;
|
||||
|
||||
function parse (uriString) {
|
||||
// do not use require('url').parse b/c it can't handle # in username or pwd
|
||||
// mongo uris are strange
|
||||
|
||||
var uri = uriString;
|
||||
var ret = {};
|
||||
var parts;
|
||||
var auth;
|
||||
var ipcs;
|
||||
|
||||
// skip protocol
|
||||
uri = uri.replace(/^mongodb:\/\//, '');
|
||||
|
||||
// auth
|
||||
if (/@/.test(uri)) {
|
||||
parts = uri.split(/@/);
|
||||
auth = parts[0];
|
||||
uri = parts[1];
|
||||
|
||||
parts = auth.split(':');
|
||||
ret.auth = {};
|
||||
ret.auth.user = parts[0];
|
||||
ret.auth.pass = parts[1];
|
||||
}
|
||||
|
||||
// unix domain sockets
|
||||
if (ipcRgx.test(uri)) {
|
||||
ipcs = uri.split(ipcRgx);
|
||||
ret.ipc = ipcs[0] + '.sock';
|
||||
|
||||
// included a database?
|
||||
if (ipcs[1]) {
|
||||
// strip leading / from database name
|
||||
ipcs[1] = ipcs[1].replace(/^\//, '');
|
||||
|
||||
if (ipcs[1]) {
|
||||
ret.db = ipcs[1];
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// database name
|
||||
parts = uri.split('/');
|
||||
if (parts[1]) ret.db = parts[1];
|
||||
|
||||
// host:port
|
||||
parts = parts[0].split(':');
|
||||
ret.host = parts[0];
|
||||
ret.port = parts[1] || DEFAULT_PORT;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Version
|
||||
*/
|
||||
|
||||
module.exports.version = JSON.parse(
|
||||
require('fs').readFileSync(__dirname + '/../package.json', 'utf8')
|
||||
).version;
|
||||
77
node_modules/muri/package.json
generated
vendored
Normal file
77
node_modules/muri/package.json
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"muri@1.0.0",
|
||||
"/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/mongoose"
|
||||
]
|
||||
],
|
||||
"_from": "muri@1.0.0",
|
||||
"_id": "muri@1.0.0",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/muri",
|
||||
"_npmUser": {
|
||||
"email": "aaron.heckmann@gmail.com",
|
||||
"name": "aaron"
|
||||
},
|
||||
"_npmVersion": "1.4.4",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "muri",
|
||||
"raw": "muri@1.0.0",
|
||||
"rawSpec": "1.0.0",
|
||||
"scope": null,
|
||||
"spec": "1.0.0",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/mongoose"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/muri/-/muri-1.0.0.tgz",
|
||||
"_shasum": "de3bf6bd71d67eae71d76689b950d2de118695c6",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "muri@1.0.0",
|
||||
"_where": "/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/mongoose",
|
||||
"author": {
|
||||
"email": "aaron.heckmann+github@gmail.com",
|
||||
"name": "Aaron Heckmann"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/aheckmann/muri/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "MongoDB URI parser",
|
||||
"devDependencies": {
|
||||
"mocha": "1.21.5"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "de3bf6bd71d67eae71d76689b950d2de118695c6",
|
||||
"tarball": "http://registry.npmjs.org/muri/-/muri-1.0.0.tgz"
|
||||
},
|
||||
"homepage": "https://github.com/aheckmann/muri",
|
||||
"keywords": [
|
||||
"mongodb",
|
||||
"parser",
|
||||
"uri"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "aaron",
|
||||
"email": "aaron.heckmann+github@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "muri",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/aheckmann/muri.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
||||
3
node_modules/muri/strict.js
generated
vendored
Normal file
3
node_modules/muri/strict.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
var x = require('./')('mongodb://asdf:pass@your:2342/hilllo');
|
||||
312
node_modules/muri/test/index.js
generated
vendored
Normal file
312
node_modules/muri/test/index.js
generated
vendored
Normal file
@@ -0,0 +1,312 @@
|
||||
|
||||
var muri = require('../')
|
||||
var assert = require('assert')
|
||||
|
||||
describe('muri', function(){
|
||||
it('must begin with mongodb://', function(done){
|
||||
assert.throws(function () {
|
||||
muri('localhost:27017');
|
||||
}, /Invalid mongodb uri/);
|
||||
assert.doesNotThrow(function () {
|
||||
muri('mongodb://localhost:27017');
|
||||
})
|
||||
done();
|
||||
})
|
||||
|
||||
describe('user:password', function(done){
|
||||
it('is optional', function(done){
|
||||
var uri = 'mongodb://local:27017';
|
||||
var val = muri(uri);
|
||||
assert.ok(!val.auth);
|
||||
done();
|
||||
})
|
||||
|
||||
it('parses properly', function(done){
|
||||
var uri = 'mongodb://user:password@local:27017';
|
||||
var val = muri(uri);
|
||||
assert.ok(val.auth);
|
||||
assert.equal('user', val.auth.user);
|
||||
assert.equal('password', val.auth.pass);
|
||||
done();
|
||||
})
|
||||
|
||||
it('handles # in the username', function(done){
|
||||
var uri = 'mongodb://us#er:password@local:27017';
|
||||
var val = muri(uri);
|
||||
assert.ok(val.auth);
|
||||
assert.equal('us#er', val.auth.user);
|
||||
assert.equal('password', val.auth.pass);
|
||||
done();
|
||||
})
|
||||
|
||||
it('handles # in the password', function(done){
|
||||
var uri = 'mongodb://user:pa#ssword@local:27017';
|
||||
var val = muri(uri);
|
||||
assert.ok(val.auth);
|
||||
assert.equal('user', val.auth.user);
|
||||
assert.equal('pa#ssword', val.auth.pass);
|
||||
done();
|
||||
})
|
||||
})
|
||||
|
||||
describe('host', function(){
|
||||
it('must be specified', function(done){
|
||||
assert.throws(function () {
|
||||
muri('mongodb://');
|
||||
}, /Missing host/)
|
||||
assert.throws(function () {
|
||||
muri('mongodb:///fake');
|
||||
}, /Missing host/)
|
||||
assert.throws(function () {
|
||||
muri('mongodb://?yep');
|
||||
}, /Missing host/)
|
||||
assert.throws(function () {
|
||||
muri('mongodb:///?yep');
|
||||
}, /Missing host/)
|
||||
|
||||
var val = muri('mongodb://local');
|
||||
assert.ok(Array.isArray(val.hosts));
|
||||
assert.equal(1, val.hosts.length);
|
||||
assert.equal('local', val.hosts[0].host);
|
||||
done();
|
||||
})
|
||||
|
||||
it('supports replica sets', function(done){
|
||||
var val = muri('mongodb://local:27017,remote:27018,japan:99999');
|
||||
assert.ok(Array.isArray(val.hosts));
|
||||
assert.equal(3, val.hosts.length);
|
||||
assert.equal('local', val.hosts[0].host);
|
||||
assert.equal(27017, val.hosts[0].port);
|
||||
assert.equal('remote', val.hosts[1].host);
|
||||
assert.equal(27018, val.hosts[1].port);
|
||||
assert.equal('japan', val.hosts[2].host);
|
||||
assert.equal(99999, val.hosts[2].port);
|
||||
done();
|
||||
})
|
||||
})
|
||||
|
||||
describe('port', function(){
|
||||
|
||||
describe('with single host', function(){
|
||||
it('defaults to 27017 if not specified', function(done){
|
||||
var val = muri('mongodb://local/');
|
||||
assert.equal(27017, val.hosts[0].port);
|
||||
done();
|
||||
})
|
||||
|
||||
it('uses what is specified', function(done){
|
||||
var val = muri('mongodb://local:27018');
|
||||
assert.equal(27018, val.hosts[0].port);
|
||||
done();
|
||||
})
|
||||
})
|
||||
|
||||
describe('with replica sets', function(){
|
||||
var val;
|
||||
|
||||
before(function(){
|
||||
val = muri('mongodb://local,remote:27018,another');
|
||||
})
|
||||
|
||||
it('defaults to 27017 if not specified', function(done){
|
||||
assert.equal(27017, val.hosts[0].port);
|
||||
assert.equal(27017, val.hosts[2].port);
|
||||
done();
|
||||
})
|
||||
|
||||
it('uses what is specified', function(done){
|
||||
assert.equal(27018, val.hosts[1].port);
|
||||
done();
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('database', function(){
|
||||
it('default', function(done){
|
||||
var val = muri('mongodb://localhost/');
|
||||
assert.equal('test', val.db);
|
||||
var val = muri('mongodb://localhost');
|
||||
assert.equal('test', val.db);
|
||||
done();
|
||||
})
|
||||
it('is overridable', function(done){
|
||||
var val = muri('mongodb://localhost,a,x:34343,b/muri');
|
||||
assert.equal('muri', val.db);
|
||||
done();
|
||||
})
|
||||
it('works with multiple specified protocols', function(done){
|
||||
var uri = 'mongodb://localhost:27020/testing,mongodb://localhost:27019,mongodb://localhost:27018'
|
||||
var val = muri(uri);
|
||||
assert.equal('testing', val.db);
|
||||
done();
|
||||
})
|
||||
})
|
||||
|
||||
describe('querystring separator', function(){
|
||||
it('can be ; ', function(done){
|
||||
var val = muri('mongodb://muri/?replicaSet=myreplset;slaveOk=true;x=1');
|
||||
assert.ok(val.options);
|
||||
assert.equal(true, val.options.slaveOk);
|
||||
assert.equal('myreplset', val.options.replicaSet);
|
||||
assert.equal(1, val.options.x);
|
||||
done();
|
||||
})
|
||||
it('can be & ', function(done){
|
||||
var val = muri('mongodb://muri/?replicaSet=myreplset&slaveOk=true&x=1');
|
||||
assert.ok(val.options);
|
||||
assert.equal(true, val.options.slaveOk);
|
||||
assert.equal('myreplset', val.options.replicaSet);
|
||||
assert.equal(1, val.options.x);
|
||||
done();
|
||||
})
|
||||
})
|
||||
|
||||
describe('readPref tags', function(){
|
||||
describe('with & ', function(){
|
||||
it('mongodb://localhost/?readPreferenceTags=dc:ny', function(done){
|
||||
var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny');
|
||||
assert.equal('test', val.db);
|
||||
assert.deepEqual([{ dc: 'ny' }], val.options.readPreferenceTags);
|
||||
done();
|
||||
})
|
||||
it('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1', function(done){
|
||||
var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1');
|
||||
assert.deepEqual([{ dc: 'ny', rack: 1 }], val.options.readPreferenceTags);
|
||||
done();
|
||||
})
|
||||
it('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:sf,rack:2', function(done){
|
||||
var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:sf,rack:2');
|
||||
assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'sf', rack: 2 }], val.options.readPreferenceTags);
|
||||
done();
|
||||
})
|
||||
it('mongodb://localhost/db?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:sf,rack:2&readPreferenceTags=', function(done){
|
||||
var val = muri('mongodb://localhost/db?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:sf,rack:2&readPreferenceTags=');
|
||||
assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'sf', rack: 2 }], val.options.readPreferenceTags);
|
||||
done();
|
||||
})
|
||||
it('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:ny&readPreferenceTags=', function(done){
|
||||
var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:ny&readPreferenceTags=');
|
||||
assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'ny' }], val.options.readPreferenceTags);
|
||||
done();
|
||||
})
|
||||
})
|
||||
describe('with ; ', function(){
|
||||
it('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:sf,rack:2', function(done){
|
||||
var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:sf,rack:2');
|
||||
assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'sf', rack: 2 }], val.options.readPreferenceTags);
|
||||
done();
|
||||
})
|
||||
it('mongodb://localhost/db?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:sf,rack:2;readPreferenceTags=', function(done){
|
||||
var val = muri('mongodb://localhost/db?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:sf,rack:2;readPreferenceTags=');
|
||||
assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'sf', rack: 2 }], val.options.readPreferenceTags);
|
||||
done();
|
||||
})
|
||||
it('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:ny;readPreferenceTags=', function(done){
|
||||
var val = muri('mongodb://localhost/?readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:ny;readPreferenceTags=');
|
||||
assert.deepEqual([{ dc: 'ny', rack: 1 }, { dc: 'ny' }], val.options.readPreferenceTags);
|
||||
done();
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('unix domain sockets', function(){
|
||||
it('without auth', function(done){
|
||||
var val = muri('mongodb:///tmp/mongodb-27017.sock?safe=false');
|
||||
assert.equal(val.db, 'test')
|
||||
assert.ok(Array.isArray(val.hosts));
|
||||
assert.equal(1, val.hosts.length);
|
||||
assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
|
||||
assert.equal(val.hosts[0].host, undefined);
|
||||
assert.equal(val.hosts[0].port, undefined);
|
||||
assert.equal(false, val.options.safe);
|
||||
done();
|
||||
})
|
||||
it('without auth with a database name', function(done){
|
||||
var val = muri('mongodb:///tmp/mongodb-27017.sock/tester?safe=false');
|
||||
assert.equal(val.db, 'tester')
|
||||
assert.ok(Array.isArray(val.hosts));
|
||||
assert.equal(1, val.hosts.length);
|
||||
assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
|
||||
assert.equal(val.hosts[0].host, undefined);
|
||||
assert.equal(val.hosts[0].port, undefined);
|
||||
assert.equal(false, val.options.safe);
|
||||
done();
|
||||
})
|
||||
it('with auth', function(done){
|
||||
var val = muri('mongodb://user:password@/tmp/mongodb-27017.sock?safe=false');
|
||||
assert.equal(val.db, 'admin')
|
||||
assert.ok(Array.isArray(val.hosts));
|
||||
assert.equal(1, val.hosts.length);
|
||||
assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
|
||||
assert.equal(val.hosts[0].host, undefined);
|
||||
assert.equal(val.hosts[0].port, undefined);
|
||||
assert.equal(false, val.options.safe);
|
||||
done();
|
||||
})
|
||||
it('with auth with a db name', function(done){
|
||||
var val = muri('mongodb://user:password@/tmp/mongodb-27017.sock/tester?safe=false');
|
||||
assert.equal(val.db, 'tester')
|
||||
assert.ok(Array.isArray(val.hosts));
|
||||
assert.equal(1, val.hosts.length);
|
||||
assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
|
||||
assert.equal(val.hosts[0].host, undefined);
|
||||
assert.equal(val.hosts[0].port, undefined);
|
||||
assert.equal(false, val.options.safe);
|
||||
done();
|
||||
})
|
||||
it('with auth + repl sets', function(done){
|
||||
var val = muri('mongodb://user:password@/tmp/mongodb-27017.sock,/tmp/another-27018.sock?safe=false');
|
||||
assert.equal(val.db, 'admin')
|
||||
assert.ok(Array.isArray(val.hosts));
|
||||
assert.equal(2, val.hosts.length);
|
||||
assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
|
||||
assert.equal(val.hosts[0].host, undefined);
|
||||
assert.equal(val.hosts[0].port, undefined);
|
||||
assert.equal(val.hosts[1].ipc, '/tmp/another-27018.sock')
|
||||
assert.equal(val.hosts[1].host, undefined);
|
||||
assert.equal(val.hosts[1].port, undefined);
|
||||
assert.equal(false, val.options.safe);
|
||||
done();
|
||||
})
|
||||
it('with auth + repl sets with a db name', function(done){
|
||||
var val = muri('mongodb://user:password@/tmp/mongodb-27017.sock,/tmp/another-27018.sock/tester?safe=false');
|
||||
assert.equal(val.db, 'tester')
|
||||
assert.ok(Array.isArray(val.hosts));
|
||||
assert.equal(2, val.hosts.length);
|
||||
assert.equal(val.hosts[0].ipc, '/tmp/mongodb-27017.sock')
|
||||
assert.equal(val.hosts[0].host, undefined);
|
||||
assert.equal(val.hosts[0].port, undefined);
|
||||
assert.equal(val.hosts[1].ipc, '/tmp/another-27018.sock')
|
||||
assert.equal(val.hosts[1].host, undefined);
|
||||
assert.equal(val.hosts[1].port, undefined);
|
||||
assert.equal(false, val.options.safe);
|
||||
done();
|
||||
})
|
||||
})
|
||||
|
||||
it('all together now', function(done){
|
||||
var uri = 'mongodb://u#ser:pas#s@local,remote:27018,japan:27019/neatdb'
|
||||
uri += '?replicaSet=myreplset&journal=true&w=2&wtimeoutMS=50'
|
||||
var val = muri(uri);
|
||||
|
||||
assert.equal('u#ser', val.auth.user);
|
||||
assert.equal('pas#s', val.auth.pass);
|
||||
assert.equal('neatdb', val.db);
|
||||
assert.equal(3, val.hosts.length);
|
||||
assert.equal('local', val.hosts[0].host);
|
||||
assert.strictEqual(27017, val.hosts[0].port);
|
||||
assert.equal('remote', val.hosts[1].host);
|
||||
assert.strictEqual(27018, val.hosts[1].port);
|
||||
assert.equal('japan', val.hosts[2].host);
|
||||
assert.strictEqual(27019, val.hosts[2].port);
|
||||
assert.equal('myreplset', val.options.replicaSet);
|
||||
assert.equal(true, val.options.journal);
|
||||
assert.equal(50, val.options.wtimeoutMS);
|
||||
done();
|
||||
})
|
||||
|
||||
it('has a version', function(done){
|
||||
assert.ok(muri.version);
|
||||
done();
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user