Fix problem with beaker saver and default index pages

As discussed on the mailing list, we need to check for a URL that is
missing the default `/index.html`

https://groups.google.com/d/msg/tiddlywikidev/n6yUdu2zHWo/m32R2BuIDgAJ
This commit is contained in:
Jermolene 2016-12-29 16:45:47 +00:00
parent eac449e8ff
commit ab1b1f2cde
1 changed files with 11 additions and 3 deletions

View File

@ -20,10 +20,18 @@ var BeakerSaver = function(wiki) {
};
BeakerSaver.prototype.save = function(text,method,callback) {
dat.writeFile(document.location.protocol + "//" + document.location.hostname + ":" + document.location.port + document.location.pathname,text,"utf8").then(function(value) {
callback(null);
var url = (location.toString()).split("#")[0];
dat.stat(url).then(function(value) {
if(value.type === "directory") {
url = url + "/index.html";
}
dat.writeFile(url,text,"utf8").then(function(value) {
callback(null);
},function(reason) {
callback("Beaker Saver Write Error: " + reason);
});
},function(reason) {
callback("Beaker Saver Error: " + reason);
callback("Beaker Saver Stat Error: " + reason);
});
return true;
};