3 var url = require('url');
5 function normalizeRedirect(roomUrl, req) {
6 var pathname = url.parse(roomUrl).pathname;
8 // Do we need to add the subframe on too?
9 var m = req.path.match(/\/~\w+$/);
10 var frame = (m && m[0]) || '';
12 pathname = pathname + frame;
14 pathname = encodeURI(pathname);
16 return url.format({ pathname: pathname, query: req.query });
19 module.exports = normalizeRedirect;