diff --git a/dist/nohost-sw.js b/dist/nohost-sw.js index 06cdae5..cc1af34 100644 --- a/dist/nohost-sw.js +++ b/dist/nohost-sw.js @@ -17,6 +17,6 @@ module.exports.back="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAWBAMAA },{}],"/tkn":[function(require,module,exports) { "use strict";var n=require("filer"),e=n.fs,t=n.Path,i=require("./config"),o=i.route,r=i.disableIndexes,c=i.directoryIndex,f=new e.Shell;function a(n,e){var i=t.basename(n),o=e.mtime.toUTCString();return'attachment; filename="'.concat(i,'"; modification-date="').concat(o,'"; size=').concat(e.size,";")}var s=function(n,i,s){return new Promise(function(u){function d(n){return new Response(n.body,n.config)}function m(n,e){if("ENOENT"===e.code)return u(d(i.format404(n)));u(d(i.format500(n,e)))}function l(n,t){e.readFile(n,function(e,o){if(e)return m(n,e);var r=i.formatFile(n,o,t);200===r.config.status&&s&&(r.config.headers["Content-Disposition"]=a(n,t)),u(new Response(r.body,r.config))})}function g(n){var a;a=t.join(n,c),e.stat(a,function(e,t){e?"ENOENT"!==e.code||r?m(n,e):f.ls(n,function(e,t){if(e)return m(n,e);var r=i.formatDir(o,n,t);u(new Response(r.body,r.config))}):l(a,t)})}e.stat(n,function(e,t){if(e)return m(n,e);t.isDirectory()?g(n):l(n,t)})})};module.exports.serve=s; },{"filer":"KyOv","./config":"4itQ"}],"JQ+3":[function(require,module,exports) { -var e=require("./json-formatter"),r=require("./html-formatter"),o=require("./webserver"),t=o.serve,a=require("./config"),n=a.debug,s=a.route;importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.1.1/workbox-sw.js"),workbox.setConfig({debug:n});var i=new RegExp("".concat(s,"(/.*)")),c=new RegExp("".concat(s,"$"));workbox.routing.registerRoute(i,function(o){var a=o.url,n=a.pathname.match(i)[1];n=decodeURIComponent(n);var s=null!==a.searchParams.get("json")?e:r,c=null!==a.searchParams.get("download")||null!==a.searchParams.get("dl");return t(n,s,c)},"GET"),workbox.routing.registerRoute(c,function(e){var r=e.url;return r.pathname="".concat(s,"/"),Promise.resolve(Response.redirect(r,302))},"GET"),workbox.core.skipWaiting(),workbox.core.clientsClaim(); +var e=require("./json-formatter"),r=require("./html-formatter"),o=require("./webserver"),t=o.serve,a=require("./config"),n=a.debug,s=a.route;importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.1.1/workbox-sw.js"),workbox.setConfig({debug:n});var i=new RegExp("".concat(s,"(/.*)")),c=new RegExp("".concat(s,"$"));workbox.routing.registerRoute(i,function(o){var a=o.url,n=a.pathname.match(i)[1];n=decodeURI(n);var s=null!==a.searchParams.get("json")?e:r,c=null!==a.searchParams.get("download")||null!==a.searchParams.get("dl");return t(n,s,c)},"GET"),workbox.routing.registerRoute(c,function(e){var r=e.url;return r.pathname="".concat(s,"/"),Promise.resolve(Response.redirect(r,302))},"GET"),workbox.core.skipWaiting(),workbox.core.clientsClaim(); },{"./json-formatter":"55+A","./html-formatter":"0nsJ","./webserver":"/tkn","./config":"4itQ"}]},{},["JQ+3"], null) //# sourceMappingURL=/nohost-sw.js.map \ No newline at end of file diff --git a/example/index.js b/example/index.js index 37098a9..7ca5a06 100644 --- a/example/index.js +++ b/example/index.js @@ -10,7 +10,7 @@ function serverInstall() { console.log('Server installed for first time'); const fs = window.Filer.fs; - fs.writeFile('/hello world.txt', 'hello world!', function(err) { + fs.writeFile('/The Bridge.txt', 'hello world!', function(err) { if(err) console.error(err); }); } diff --git a/src/nohost-sw.js b/src/nohost-sw.js index f7f226c..a64ab8d 100644 --- a/src/nohost-sw.js +++ b/src/nohost-sw.js @@ -20,7 +20,7 @@ workbox.routing.registerRoute( // Pull the filesystem path off the url let path = url.pathname.match(wwwRegex)[1]; // Deal with encoding in the filename (e.g., spaces as %20) - path = decodeURIComponent(path); + path = decodeURI(path); // Allow passing `?json` on URL to get back JSON vs. raw response const formatter =