From 887585c7a565d41390d5eacf07eff8d2f200cc2c Mon Sep 17 00:00:00 2001 From: Tomi Nokkala Date: Fri, 1 Nov 2013 13:58:00 +0200 Subject: [PATCH 1/2] Allow special characters on database name with fti and replicate --- lib/cradle/database/index.js | 2 +- lib/cradle/database/views.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cradle/database/index.js b/lib/cradle/database/index.js index 9effb77..0278e6c 100644 --- a/lib/cradle/database/index.js +++ b/lib/cradle/database/index.js @@ -31,7 +31,7 @@ Database.prototype.exists = function (callback) { Database.prototype.replicate = function (target, options, callback) { if (typeof(options) === 'function') { callback = options, options = {} } - this.connection.replicate(cradle.merge({ source: this.name, target: target }, options), callback); + this.connection.replicate(cradle.merge({ source: decodeURIComponent(this.name), target: target }, options), callback); }; Database.prototype.info = function (callback) { diff --git a/lib/cradle/database/views.js b/lib/cradle/database/views.js index 9d76e2f..1db6bd0 100644 --- a/lib/cradle/database/views.js +++ b/lib/cradle/database/views.js @@ -33,7 +33,7 @@ Database.prototype.fti = function (path, options, callback) { } path = path.split('/'); - path = ['_fti', 'local', this.name, '_design', path[0], path[1]].map(querystring.escape).join('/'); + path = ['_fti', 'local', decodeURIComponent(this.name), '_design', path[0], path[1]].map(querystring.escape).join('/'); options = parseOptions(options); From dd59aba46bdc93aa686903aa6115cf6dab2579da Mon Sep 17 00:00:00 2001 From: Tomi Nokkala Date: Wed, 13 Nov 2013 15:17:32 +0200 Subject: [PATCH 2/2] Add unEscapedName to fetch unescaped name --- .gitignore | 3 ++- lib/cradle/database/index.js | 3 ++- lib/cradle/database/views.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 lib/cradle/database/index.js mode change 100644 => 100755 lib/cradle/database/views.js diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 28a59dc..f3ba0ad --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules npm-debug.log test/fixtures/README.md -test/fixtures/not-found.txt \ No newline at end of file +test/fixtures/not-found.txt +.idea \ No newline at end of file diff --git a/lib/cradle/database/index.js b/lib/cradle/database/index.js old mode 100644 new mode 100755 index 0278e6c..1d69ebe --- a/lib/cradle/database/index.js +++ b/lib/cradle/database/index.js @@ -5,6 +5,7 @@ var querystring = require('querystring'), var Database = exports.Database = function (name, connection) { this.connection = connection; this.name = encodeURIComponent(name); + this.unEscapedName = name; this.cache = new (cradle.Cache)(connection.options); }; @@ -31,7 +32,7 @@ Database.prototype.exists = function (callback) { Database.prototype.replicate = function (target, options, callback) { if (typeof(options) === 'function') { callback = options, options = {} } - this.connection.replicate(cradle.merge({ source: decodeURIComponent(this.name), target: target }, options), callback); + this.connection.replicate(cradle.merge({ source: this.unEscapedName, target: target }, options), callback); }; Database.prototype.info = function (callback) { diff --git a/lib/cradle/database/views.js b/lib/cradle/database/views.js old mode 100644 new mode 100755 index 1db6bd0..4fef3fe --- a/lib/cradle/database/views.js +++ b/lib/cradle/database/views.js @@ -33,7 +33,7 @@ Database.prototype.fti = function (path, options, callback) { } path = path.split('/'); - path = ['_fti', 'local', decodeURIComponent(this.name), '_design', path[0], path[1]].map(querystring.escape).join('/'); + path = ['_fti', 'local', this.unEscapedName, '_design', path[0], path[1]].map(querystring.escape).join('/'); options = parseOptions(options);