From 251e9ad70c6851023f6765fa5b5a6fdcc8456b2a Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Tue, 4 Aug 2009 17:25:17 +0000 Subject: encode slashes in db names in Location response header after database creation, move couch_rep:url_encode/1 to couch_util:url_encode/1, closes COUCHDB-411 git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@800883 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/basics.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'share/www/script/test') diff --git a/share/www/script/test/basics.js b/share/www/script/test/basics.js index 5e26360f..3979d860 100644 --- a/share/www/script/test/basics.js +++ b/share/www/script/test/basics.js @@ -29,15 +29,19 @@ couchTests.basics = function(debug) { if (debug) debugger; // creating a new DB should return Location header - xhr = CouchDB.request("DELETE", "/test_suite_db"); - xhr = CouchDB.request("PUT", "/test_suite_db"); - TEquals("/test_suite_db", - xhr.getResponseHeader("Location").substr(-14), - "should return Location header to newly created document"); - - TEquals("http://", - xhr.getResponseHeader("Location").substr(0, 7), - "should return absolute Location header to newly created document"); + // and it should work for dbs with slashes (COUCHDB-411) + var dbnames = ["test_suite_db", "test_suite_db%2Fwith_slashes"]; + dbnames.forEach(function(dbname) { + xhr = CouchDB.request("DELETE", "/" + dbname); + xhr = CouchDB.request("PUT", "/" + dbname); + TEquals(dbname, + xhr.getResponseHeader("Location").substr(-dbname.length), + "should return Location header to newly created document"); + + TEquals("http://", + xhr.getResponseHeader("Location").substr(0, 7), + "should return absolute Location header to newly created document"); + }); // Get the database info, check the db_name T(db.info().db_name == "test_suite_db"); -- cgit v1.2.3