File size: 396 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Redirect any route ?thread=<id> or ?t=<id> to /thread/<id>

const threadParamRedirect = (req, res, next) => {
  const threadId = req.query.thread || req.query.t;

  if (threadId) {
    if (req.query.m) {
      res.redirect(`/thread/${threadId}?m=${req.query.m}`);
    } else {
      res.redirect(`/thread/${threadId}`);
    }
  } else {
    next();
  }
};

export default threadParamRedirect;