diff --git a/node/server.js b/node/server.js index 68b7ab6ab..0f7807619 100644 --- a/node/server.js +++ b/node/server.js @@ -257,22 +257,23 @@ async.waterfall([ }); }); - //serve pad.html under /p - app.get('/p/:pad', function(req, res, next) + //serve pad.html under / and /p for compatibility + app.get( '(/p)?/:pad', function(req, res, next) { var filePath = path.normalize(__dirname + "/../static/pad.html"); res.sendfile(filePath, { maxAge: exports.maxAge }); }); - //serve timeslider.html under /p/$padname/timeslider - app.get('/p/:pad/timeslider', function(req, res, next) + //serve timeslider.html under /$padname/timeslider or /p/$padname/timeslider + app.get('(/p)?/:pad/timeslider', function(req, res, next) { var filePath = path.normalize(__dirname + "/../static/timeslider.html"); res.sendfile(filePath, { maxAge: exports.maxAge }); }); - //serve timeslider.html under /p/$padname/timeslider - app.get('/p/:pad/:rev?/export/:type', function(req, res, next) + //handle export requests + // app.get('(/p)?/:pad/:rev?/export/:type', function(req, res, next) + app.get('/:pad/:rev?/export/:type', function(req, res, next) { var types = ["pdf", "doc", "txt", "html", "odt", "dokuwiki"]; //send a 404 if we don't support this filetype diff --git a/static/js/pad_impexp.js b/static/js/pad_impexp.js index 0037195f2..76e994f16 100644 --- a/static/js/pad_impexp.js +++ b/static/js/pad_impexp.js @@ -240,9 +240,9 @@ var padimpexp = (function() { pad = _pad; - //get /p/padname - var pad_root_path = new RegExp(/.*\/p\/[^\/]+/).exec(document.location.pathname) - //get http://example.com/p/padname + //get /p/padname or /padname + var pad_root_path = new RegExp(/.*\/[^\/]+/).exec(document.location.pathname) + //get http://example.com/p/padname or http://example.com/padname var pad_root_url = document.location.href.replace(document.location.pathname, pad_root_path) // build the export links