fix latent javascript replace-with-'' bug

This commit is contained in:
Jonathan Lipps
2014-04-24 17:27:30 -07:00
parent b45fea1e21
commit 3cdaf1bda0

View File

@@ -42,12 +42,16 @@ module.exports.doProxy = function (req, res) {
req.device.proxyPort);
var sessRe = new RegExp('^/wd/hub/session/([^/]+)');
var sessionRegxMatch = sessRe.exec(req.originalUrl);
// there might be no session id in the orig. req. if so, consider it to be a
// blank string
var origSessId = sessionRegxMatch ? sessionRegxMatch[1] : '';
var sessId = req.device.proxySessionId ? req.device.proxySessionId :
origSessId;
var newPath = req.originalUrl.replace(origSessId, sessId);
var newPath;
// there might be no session id in the orig. req.
if (sessionRegxMatch) {
var origSessId = sessionRegxMatch[1];
var sessId = req.device.proxySessionId ? req.device.proxySessionId :
origSessId;
newPath = req.originalUrl.replace(origSessId, sessId);
} else {
newPath = req.originalUrl;
}
var url = 'http://' + req.device.proxyHost + ':' + req.device.proxyPort +
newPath;
doRequest(url, req.route.method.toUpperCase(), req.body,