summaryrefslogtreecommitdiff
path: root/share/www/script/jquery.couch.js
diff options
context:
space:
mode:
authorChristopher Lenz <cmlenz@apache.org>2009-07-21 21:16:56 +0000
committerChristopher Lenz <cmlenz@apache.org>2009-07-21 21:16:56 +0000
commit4fa38ad4e4245f27776b4269634a98212bbae3e8 (patch)
tree15c354c16f33c31df257c7bff79f54249b47ab72 /share/www/script/jquery.couch.js
parent1ddff48dbb8f18d3bde189477827164528a8d938 (diff)
Fix for compatibility of Futon with design documents that have slashes in the document ID or a view name. Closes COUCHDB-408 (again).
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@796541 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script/jquery.couch.js')
-rw-r--r--share/www/script/jquery.couch.js18
1 files changed, 15 insertions, 3 deletions
diff --git a/share/www/script/jquery.couch.js b/share/www/script/jquery.couch.js
index 5d659843..1d83a91d 100644
--- a/share/www/script/jquery.couch.js
+++ b/share/www/script/jquery.couch.js
@@ -12,6 +12,16 @@
(function($) {
$.couch = $.couch || {};
+
+ function encodeDocId(docID) {
+ var parts = docID.split("/");
+ if (parts[0] == "_design") {
+ parts.shift();
+ return "_design/" + encodeURIComponent(parts.join('/'));
+ }
+ return encodeURIComponent(docID);
+ }
+
$.extend($.couch, {
activeTasks: function(options) {
ajax(
@@ -127,7 +137,7 @@
}
},
openDoc: function(docId, options, ajaxOptions) {
- ajax({url: this.uri + encodeURIComponent(docId) + encodeOptions(options)},
+ ajax({url: this.uri + encodeDocId(docId) + encodeOptions(options)},
options,
"The document could not be retrieved",
ajaxOptions
@@ -140,7 +150,7 @@
var uri = this.uri;
} else {
var method = "PUT";
- var uri = this.uri + encodeURIComponent(doc._id);
+ var uri = this.uri + encodeDocId(doc._id);
}
$.ajax({
type: method, url: uri + encodeOptions(options),
@@ -174,7 +184,7 @@
ajax({
type: "DELETE",
url: this.uri +
- encodeURIComponent(doc._id) +
+ encodeDocId(doc._id) +
encodeOptions({rev: doc._rev})
},
options,
@@ -213,6 +223,8 @@
};
},
+ encodeDocId: encodeDocId,
+
info: function(options) {
ajax(
{url: "/"},