Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added uri encoding in the relax function being applied to db property.

added a test for this.
not really 100% sure it works, but all tests are passing.
  • Loading branch information...
commit f9690bc2c4ef74a40d5734fc0a8d974445a20f9f 1 parent c2ee0d0
@boxxxie boxxxie authored committed
Showing with 20 additions and 2 deletions.
  1. +1 −1  nano.js
  2. +10 −1 tests/db/create.js
  3. +9 −0 tests/fixtures/db/create.json
View
2  nano.js
@@ -124,7 +124,7 @@ module.exports = exports = nano = function database_module(cfg) {
}
if(opts.db) {
- req.uri = u.resolve(req.uri, opts.db);
+ req.uri = u.resolve(req.uri, encodeURIComponent(opts.db));
}
if (opts.headers) {
View
11 tests/db/create.js
@@ -13,10 +13,19 @@ specify("db_create:test", timeout, function (assert) {
});
});
+specify("db_create:encoded_name", timeout, function (assert) {
+ nano.db.create("az09_$()+-/", function (err) {
+ assert.equal(err, undefined, "Failed to create database");
+ });
+});
+
specify("db_create:teardown", timeout, function (assert) {
nano.db.destroy("db_create", function (err) {
assert.equal(err, undefined, "Failed to destroy database");
- assert.ok(mock.isDone(), "Some mocks didn't run");
+ nano.db.destroy("az09_$()+-/", function (err) {
+ assert.equal(err, undefined, "Failed to destroy database");
+ assert.ok(mock.isDone(), "Some mocks didn't run");
+ });
});
});
View
9 tests/fixtures/db/create.json
@@ -4,8 +4,17 @@
, "status" : 201
, "response" : "{ \"ok\": true }"
}
+, { "method" : "put"
+ , "path" : "/az09_%24()%2B-%2F"
+ , "status" : 201
+ , "response" : "{ \"ok\": true }"
+ }
, { "method" : "delete"
, "path" : "/db_create"
, "response" : "{ \"ok\": true }"
}
+, { "method" : "delete"
+ , "path" : "/az09_%24()%2B-%2F"
+ , "response" : "{ \"ok\": true }"
+ }
]
Please sign in to comment.
Something went wrong with that request. Please try again.