Node.js based forum software built for the modern web
file upload with spaces / general file upload fix wrt ajaxiy
psychobunny3ed3612047c4
diff --git a/public/src/ajaxify.js b/public/src/ajaxify.jsindex 75e341643e..0c4e191532 100644--- a/public/src/ajaxify.js+++ b/public/src/ajaxify.js@@ -25,6 +25,8 @@ $(document).ready(function() {ajaxify.go = function (url, callback, quiet) {if (ajaxify.handleACPRedirect(url)) {return true;+ } else if (ajaxify.handleNonAPIRoutes(url)) {+ return true;}app.enterRoom('');@@ -71,6 +73,15 @@ $(document).ready(function() {return false;};+ ajaxify.handleNonAPIRoutes = function(url) {+ url = ajaxify.removeRelativePath(url.replace(/\/$/, ''));+ if (url.indexOf('uploads') === 0) {+ window.open(RELATIVE_PATH + '/' + url, '_blank');+ return true;+ }+ return false;+ };+ajaxify.start = function(url, quiet, search) {url = ajaxify.removeRelativePath(url.replace(/\/$/, ''));var hash = window.location.hash;diff --git a/src/file.js b/src/file.jsindex c98da6c761..6be1cd37c8 100644--- a/src/file.js+++ b/src/file.js@@ -8,11 +8,20 @@ var fs = require('fs'),Magic = mmmagic.Magic,mime = require('mime'),- meta= require('./meta');+ meta = require('./meta'),+ utils = require('../public/src/utils');var file = {};file.saveFileToLocal = function(filename, folder, tempPath, callback) {+ /*+ * remarkable doesn't allow spaces in hyperlinks, once that's fixed, remove this.+ */+ filename = filename.split('.');+ filename.forEach(function(name, idx) {+ filename[idx] = utils.slugify(name);+ });+ filename = filename.join('.');var uploadPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), folder, filename);@@ -23,7 +32,7 @@ file.saveFileToLocal = function(filename, folder, tempPath, callback) {is.on('end', function () {callback(null, {- url: nconf.get('upload_url') + folder + '/' + encodeURIComponent(filename)+ url: nconf.get('upload_url') + folder + '/' + filename});});