Commit bd52f34e authored by Romain Courteaud's avatar Romain Courteaud

drivetojiomapping: simplify document filtering

parent 122da4b3
...@@ -13,11 +13,13 @@ ...@@ -13,11 +13,13 @@
this._sub_storage = jIO.createJIO(spec.sub_storage); this._sub_storage = jIO.createJIO(spec.sub_storage);
} }
var DOCUMENT_EXTENSION = ".json", var DOCUMENT_EXTENSION = ".json",
DOCUMENT_REGEXP = new RegExp("^([\\w=]+)" +
DOCUMENT_EXTENSION + "$"),
DOCUMENT_KEY = "/.jio_documents/", DOCUMENT_KEY = "/.jio_documents/",
ROOT = "/"; ROOT = "/";
function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
FileSystemBridgeStorage.prototype.get = function (id) { FileSystemBridgeStorage.prototype.get = function (id) {
var context = this; var context = this;
return new RSVP.Queue() return new RSVP.Queue()
...@@ -166,8 +168,11 @@ ...@@ -166,8 +168,11 @@
var key; var key;
for (key in result) { for (key in result) {
if (result.hasOwnProperty(key)) { if (result.hasOwnProperty(key)) {
if (DOCUMENT_REGEXP.test(key)) { if (endsWith(key, DOCUMENT_EXTENSION)) {
result_dict[DOCUMENT_REGEXP.exec(key)[1]] = null; result_dict[key.substring(
0,
key.length - DOCUMENT_EXTENSION.length
)] = null;
} }
} }
} }
......
...@@ -948,6 +948,7 @@ ...@@ -948,6 +948,7 @@
return { return {
"foo.json": {}, "foo.json": {},
"bar.json": {}, "bar.json": {},
"bar.html.json": {},
"foobar.pasjson": {} "foobar.pasjson": {}
}; };
} }
...@@ -976,8 +977,11 @@ ...@@ -976,8 +977,11 @@
}, { }, {
id: "bar", id: "bar",
value: {} value: {}
}, {
id: "bar.html",
value: {}
}], }],
total_rows: 2 total_rows: 3
} }
}); });
}) })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment