Commit c49462b8 authored by Tristan Cavelier's avatar Tristan Cavelier

davstorage.js attachments id are no longer changed

If you put {
  "_id": "a.b",
  "_attachment": "compressed.tar.gz",
  "_data": ...
}, the backend will write "a_.b.compressed.tar.gz"
instead of "a_.b.compressed_.tar_.gz"
parent 1e8e41f5
...@@ -142,7 +142,7 @@ ...@@ -142,7 +142,7 @@
function idsToFileName(doc_id, attachment_id) { function idsToFileName(doc_id, attachment_id) {
doc_id = secureName(doc_id).replace(/\./g, '_.'); doc_id = secureName(doc_id).replace(/\./g, '_.');
if (typeof attachment_id === "string") { if (typeof attachment_id === "string") {
attachment_id = secureName(attachment_id).replace(/\./g, '_.'); attachment_id = secureName(attachment_id);
return doc_id + "." + attachment_id; return doc_id + "." + attachment_id;
} }
return doc_id; return doc_id;
...@@ -155,15 +155,21 @@ ...@@ -155,15 +155,21 @@
* @return {Array} ["document id", "attachment id"] or ["document id"] * @return {Array} ["document id", "attachment id"] or ["document id"]
*/ */
function fileNameToIds(file_name) { function fileNameToIds(file_name) {
return file_name.replace(/.\.(?:\.)?/g, function (substr) { /*jslint regexp: true */
if (substr[0] === '_') { file_name = /^((?:_\.|[^\.])*)(?:\.(.*))?$/.exec(file_name);
if (substr[2] === '.') { if (file_name === null ||
return '. '; (file_name[1] &&
file_name[1].length === 0)) {
return [];
} }
return '.'; if (file_name[2]) {
if (file_name[2].length > 0) {
return [restoreName(file_name[1].replace(/_\./g, '.')),
restoreName(file_name[2])];
} }
return substr[0] + ' '; return [];
}).split(' ').map(restoreName); }
return [restoreName(file_name[1].replace(/_\./g, '.'))];
} }
function promiseSucceed(promise) { function promiseSucceed(promise) {
......
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