From d83cc346e22d3109cd17b47b2d3d095302559d35 Mon Sep 17 00:00:00 2001 From: jden Date: Mon, 9 Jun 2014 13:32:17 -0400 Subject: [PATCH] fix #16 --- mongodb.js | 2 +- package.json | 4 ++-- test/mongodb.test.js | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/mongodb.js b/mongodb.js index b3b1e49..ffd4770 100644 --- a/mongodb.js +++ b/mongodb.js @@ -34,7 +34,7 @@ proto.getCollectionNames = function () { return this.db.then(function (db) { return invoke(db, 'collectionNames').then(function (names) { return names.map(function (name) { - return name.name.replace(/^\w*\./, '') + return name.name.replace(/^[^\.]*\./, '') }) }) }) diff --git a/package.json b/package.json index 2faf0de..2479680 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minq", - "version": "1.0.0-pre7", + "version": "1.0.0-pre8", "description": "fluent queries for mongodb using Promises/A+", "keywords": [ "mongodb", @@ -26,7 +26,7 @@ "chai-interface": "~1.1.0", "sinon-chai": "~2.4.0", "mocha": "~1.8.1", - "moquire": "~1.5.4" + "moquire": "^1.5.5" }, "dependencies": { "through": "~2.3.4", diff --git a/test/mongodb.test.js b/test/mongodb.test.js index a0ef230..4bd3565 100644 --- a/test/mongodb.test.js +++ b/test/mongodb.test.js @@ -119,6 +119,23 @@ describe('MongoDb', function () { }) .then(done, done) }) + it('removes db namespacing from underlying response for dbs including non alpha chars', function (done) { + // https://github.com/jden/minq/issues/16 + var MongoDb = moquire('../mongodb') + var db = { + collectionNames: function (callback) { + process.nextTick(function () { + // the mongodb driver sends back funny shaped objects: + callback(null, [{name:'test-db.foos'},{name:'test-db.bars'}]) + }) + } + } + var mongodb = new MongoDb(db) + mongodb.getCollectionNames().then(function (collectionNames) { + collectionNames.should.deep.equal(['foos','bars']) + }) + .then(done, done) + }) }) describe('#dropCollection', function () {