Permalink
Browse files

escaping some ids

  • Loading branch information...
1 parent 0d4fbf5 commit 9b40eb0445084ef481de4cb5ce2bdc7fb09d66a5 @landeiro committed Jul 14, 2011
Showing with 14 additions and 3 deletions.
  1. +14 −3 lib/PJsonCouch.js
View
17 lib/PJsonCouch.js
@@ -336,6 +336,9 @@ var PJsonCouch = function (options) {
this.saveDocAttachment = function (url, callBackFunction) {
url.args = {};
url.args.rev = url.rev;
+ if (url.id) {
+ url.id = encodeURIComponent(url.id);
+ }
var type = url.attachment.content_type;
var length = url.attachment.content_length;
var ifMatch = url.attachment.if_match;
@@ -364,6 +367,9 @@ var PJsonCouch = function (options) {
url.args = {};
url.args.rev = url.rev;
}
+ if (url.id) {
+ url.id = encodeURIComponent(url.id);
+ }
url.attachment = url.attachment.file;
var deleteOptions = this.buildRequest("DELETE", url, options);
Utils.request(deleteOptions, "", config, function (result) {
@@ -403,6 +409,9 @@ var PJsonCouch = function (options) {
};
this.getDocAttachment = function (url, callBackFunction) {
+ if (url.id) {
+ url.id = encodeURIComponent(url.id);
+ }
var encoding = url.attachment.content_encoding;
url.attachment = url.attachment.file;
var getOptions = this.buildRequest("GET", url, options);
@@ -450,13 +459,15 @@ var PJsonCouch = function (options) {
var postOptions = this.buildRequest("POST", url, options);
var extraParams = url.args;
var docs = {};
+
docs["docs"] = url.docs;
for (var idx in url.args) {
docs[idx] = url.args[idx];
+
}
- if (typeof docs !== "string") {
- docs = JSON.stringify(docs);
- }
+
+ docs = JSON.stringify(docs);
+
Utils.request(postOptions, docs, config, function (result) {
if (callBackFunction) {
callBackFunction(result);

0 comments on commit 9b40eb0

Please sign in to comment.