Commit bd52f34e authored by Romain Courteaud's avatar Romain Courteaud

drivetojiomapping: simplify document filtering

parent 122da4b3
......@@ -13,11 +13,13 @@
this._sub_storage = jIO.createJIO(spec.sub_storage);
}
var DOCUMENT_EXTENSION = ".json",
DOCUMENT_REGEXP = new RegExp("^([\\w=]+)" +
DOCUMENT_EXTENSION + "$"),
DOCUMENT_KEY = "/.jio_documents/",
ROOT = "/";
function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
FileSystemBridgeStorage.prototype.get = function (id) {
var context = this;
return new RSVP.Queue()
......@@ -166,8 +168,11 @@
var key;
for (key in result) {
if (result.hasOwnProperty(key)) {
if (DOCUMENT_REGEXP.test(key)) {
result_dict[DOCUMENT_REGEXP.exec(key)[1]] = null;
if (endsWith(key, DOCUMENT_EXTENSION)) {
result_dict[key.substring(
0,
key.length - DOCUMENT_EXTENSION.length
)] = null;
}
}
}
......
......@@ -948,6 +948,7 @@
return {
"foo.json": {},
"bar.json": {},
"bar.html.json": {},
"foobar.pasjson": {}
};
}
......@@ -976,8 +977,11 @@
}, {
id: "bar",
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