Fix tag links on org page to correctly navigate to explore page
[gitter.git] / server / handlers / org-pages.js
blobeb676a408a89105bf4f7c0d85b0b1ba98c2ac78e
1 'use strict';
3 var express = require('express');
4 var isPhoneMiddleware = require('../web/middlewares/is-phone');
5 var groupContextResolverMiddleware = require('./uri-context/group-context-resolver-middleware');
6 var featureToggles = require('../web/middlewares/feature-toggles');
7 var identifyRoute = require('gitter-web-env').middlewares.identifyRoute;
8 var redirectErrorMiddleware = require('./uri-context/redirect-error-middleware');
9 var preventClickjackingMiddleware = require('../web/middlewares/prevent-clickjacking');
10 var preventClickjackingOnlyGitterEmbedMiddleware = require('../web/middlewares/prevent-clickjacking-only-gitter-embed');
11 var router = express.Router({ caseSensitive: true, mergeParams: true });
13 /**
14  * These routes are deprecated. Use `group.homeUri` instead.
15  */
16 router.get(
17   '/:groupUri/rooms',
18   identifyRoute('group-rooms-mainframe'),
19   preventClickjackingMiddleware,
20   featureToggles,
21   isPhoneMiddleware,
22   groupContextResolverMiddleware,
23   function(req, res, next) {
24     var uriContext = req.uriContext;
25     var group = uriContext && uriContext.group;
26     var homeUri = group && group.homeUri;
28     if (homeUri) {
29       res.relativeRedirect('/' + homeUri);
30     } else {
31       return next('route');
32     }
33   },
34   redirectErrorMiddleware
37 router.get(
38   '/:groupUri/rooms/~iframe',
39   identifyRoute('group-rooms-frame'),
40   preventClickjackingOnlyGitterEmbedMiddleware,
41   featureToggles,
42   isPhoneMiddleware,
43   groupContextResolverMiddleware,
44   function(req, res, next) {
45     var uriContext = req.uriContext;
46     var group = uriContext && uriContext.group;
47     var homeUri = group && group.homeUri;
49     if (homeUri) {
50       res.relativeRedirect('/' + homeUri + '/~iframe');
51     } else {
52       return next('route');
53     }
54   },
55   redirectErrorMiddleware
58 module.exports = router;