'use strict';

var url = require('url');

var getHost = require('./get-host');

module.exports = function redirectToOrganization(req, res, organization) {
  res.redirect(req.protocol + '://' + organization.nameKey + '.' + getHost(req) + url.parse(req.url).pathname);
};

@@ -154,21 +154,18 @@
 %7B%0A  
-res.redirect(
+var uri = 
 req.
@@ -172,16 +172,20 @@
 protocol
+%0A   
  + '://'
@@ -211,14 +211,22 @@
 eKey
+%0A   
  + '.'
+%0A   
  + g
@@ -236,16 +236,20 @@
 ost(req)
+%0A   
  + url.p
@@ -270,14 +270,288 @@
 pathname
+;%0A%0A  var queryParams = Object.keys(req.query);%0A%0A  if (queryParams.length %3E 0) %7B%0A    uri += '?' + queryParams.map(function (param) %7B%0A      return encodeURIComponent(param)%0A        + '='%0A        + encodeURIComponent(req.query%5Bparam%5D);%0A    %7D).join('&');%0A  %7D%0A%0A  res.redirect(uri
 );%0A%7D;%0A

Fix behaviour for redirect with query params