From 68d63d5f8add90e48f154ab4f17d10ca8ba43cbe Mon Sep 17 00:00:00 2001
From: Tristan Cavelier <tristan.cavelier@tiolive.com>
Date: Mon, 18 Mar 2013 14:18:29 +0100
Subject: [PATCH] localstorage allDocs returns attachments, fixed.

---
 src/jio.storage/localstorage.js |  2 +-
 test/jiotests.js                | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/jio.storage/localstorage.js b/src/jio.storage/localstorage.js
index c16afe2..08e6b5b 100644
--- a/src/jio.storage/localstorage.js
+++ b/src/jio.storage/localstorage.js
@@ -347,7 +347,7 @@ jIO.addStorageType('local', function (spec, my) {
    */
   that.allDocs = function (command) {
     var i, j, file, items = 0,
-      s = new RegExp(priv.localpath + '\\/.*$'),
+      s = new RegExp("^" + priv.localpath + "\\/[^/]+$"),
       all_doc_response = {},
       query_object = [], query_syntax, query_response = [];
 
diff --git a/test/jiotests.js b/test/jiotests.js
index f707cb7..362aa44 100644
--- a/test/jiotests.js
+++ b/test/jiotests.js
@@ -1118,6 +1118,16 @@ test ("AllDocs", function(){
       o.fakeDoc.title = o.titles[i];
       o.fakeDoc.year = o.years[i];
       o.fakeDoc.author = o.director[i];
+      if (i === 5) {
+        o.fakeDoc._attachments = {
+          "att": {
+            "digest": "md5-dontcare",
+            "content_type": "text/plain",
+            "length": 3
+          }
+        };
+        localstorage.setItem(o.localpath + "/doc_05/att", "abc");
+      }
       localstorage.setItem(o.localpath+"/doc_"+(i < 10 ? "0"+i : i), o.fakeDoc);
     }
 
-- 
2.30.9