diff --git a/public/src/modules/navigator.js b/public/src/modules/navigator.js index 43b355ccf8..1b039d9b60 100644 --- a/public/src/modules/navigator.js +++ b/public/src/modules/navigator.js @@ -60,7 +60,8 @@ define('navigator', ['forum/pagination'], function(pagination) { }; function generateUrl(index) { - var parts = window.location.pathname.split('/'); + var pathname = window.location.pathname.replace(config.relative_path, ''); + var parts = pathname.split('/'); return parts[1] + '/' + parts[2] + '/' + parts[3] + (index ? '/' + index : ''); } diff --git a/src/middleware/middleware.js b/src/middleware/middleware.js index be112f810f..334e6d0b5a 100644 --- a/src/middleware/middleware.js +++ b/src/middleware/middleware.js @@ -83,7 +83,7 @@ middleware.addSlug = function(req, res, next) { return next(err); } - var url = name + encodeURI(slug); + var url = nconf.get('relative_path') + name + encodeURI(slug); if (res.locals.isAPI) { res.status(302).json(url); @@ -95,13 +95,10 @@ middleware.addSlug = function(req, res, next) { if (!req.params.slug) { if (req.params.category_id) { - redirect(categories.getCategoryField, req.params.category_id, '/category/'); + return redirect(categories.getCategoryField, req.params.category_id, '/category/'); } else if (req.params.topic_id) { - redirect(topics.getTopicField, req.params.topic_id, '/topic/'); - } else { - return next(); + return redirect(topics.getTopicField, req.params.topic_id, '/topic/'); } - return; } next(); }; diff --git a/tests/database/hash.js b/tests/database/hash.js index d35666bf53..74bfff0298 100644 --- a/tests/database/hash.js +++ b/tests/database/hash.js @@ -16,11 +16,11 @@ describe('Hash methods', function() { assert.equal(arguments.length, 1); done(); }); - }) + }); describe('setObject()', function() { it('should create a object', function(done) { - db.setObject('testObject2', testData, function(err) { + db.setObject('testObject10', testData, function(err) { assert.equal(err, null); assert.equal(arguments.length, 1); done();