From a5e565e198aace63d1c703c34ffbcc63e2475f1f Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sat, 24 Jun 2017 22:30:26 +0100 Subject: [PATCH] Tweaks for #2918 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A couple of fixes: * Fixed problem with loading saver in a file URI within Beaker * Fixed problem when saving to a directory-style URI with an implicit “/index.html” * Switched to double quotes for strings --- core/modules/savers/beaker.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/core/modules/savers/beaker.js b/core/modules/savers/beaker.js index 5b0922467..be7674338 100644 --- a/core/modules/savers/beaker.js +++ b/core/modules/savers/beaker.js @@ -20,16 +20,14 @@ var BeakerSaver = function(wiki) { this.wiki = wiki; }; -var dat = new DatArchive('' + window.location); - BeakerSaver.prototype.save = function(text,method,callback) { - var path = (location.pathname.toString()).split("#")[0]; - - dat.stat(path).then(function(value) { - if(value.isDirectory) { - path = path + "/index.html"; + var dat = new DatArchive("" + window.location), + pathname = ("" + window.location.pathname).split("#")[0]; + dat.stat(pathname).then(function(value) { + if(value.isDirectory()) { + pathname = pathname + "/index.html"; } - dat.writeFile(path,text,"utf8").then(function(value) { + dat.writeFile(pathname,text,"utf8").then(function(value) { callback(null); },function(reason) { callback("Beaker Saver Write Error: " + reason);