mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-07 15:45:54 +02:00
feat: merge
This commit is contained in:
@@ -185,9 +185,8 @@ module.exports = function (middleware) {
|
||||
if (!userslug) {
|
||||
return next();
|
||||
}
|
||||
const path = req.path.replace(/^\/api/, '')
|
||||
.replace('uid', 'user')
|
||||
.replace(uid, function () { return userslug; });
|
||||
const path = req.url.replace(/^\/api/, '')
|
||||
.replace(`/uid/${uid}`, () => `/user/${userslug}`);
|
||||
controllers.helpers.redirect(res, path);
|
||||
});
|
||||
|
||||
|
||||
@@ -1050,8 +1050,18 @@ describe('Controllers', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should 404 if user does not exist', function (done) {
|
||||
request(nconf.get('url') + '/api/uid/123123', { json: true }, function (err, res) {
|
||||
it('should redirect to userslug and keep query params', (done) => {
|
||||
request(`${nconf.get('url')}/api/uid/${fooUid}/topics?foo=bar`, { json: true }, (err, res, body) => {
|
||||
assert.ifError(err);
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.equal(res.headers['x-redirect'], '/user/foo/topics?foo=bar');
|
||||
assert.equal(body, '/user/foo/topics?foo=bar');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should 404 if user does not exist', (done) => {
|
||||
request(`${nconf.get('url')}/api/uid/123123`, { json: true }, (err, res) => {
|
||||
assert.ifError(err);
|
||||
assert.equal(res.statusCode, 404);
|
||||
done();
|
||||
|
||||
Reference in New Issue
Block a user