diff --git a/node_modules/c9/urls.js b/node_modules/c9/urls.js index 0ac974d0..e358793e 100644 --- a/node_modules/c9/urls.js +++ b/node_modules/c9/urls.js @@ -30,7 +30,7 @@ function main(options, imports, register) { * @param {String} [targetBaseUrlPattern] The target URL pattern, e.g. https://$DOMAIN */ plugin.getBaseUrl = function(req, sourceBaseUrlPattern, targetBaseUrlPattern) { - var sourceHost = req.host || req; + var sourceHost = req.headers && req.headers.host || req.host || req; var sourceHostMatcher = sourceBaseUrlPattern .replace(/^https?:\/\//, "") .replace(/\/.*/, "") @@ -39,10 +39,12 @@ plugin.getBaseUrl = function(req, sourceBaseUrlPattern, targetBaseUrlPattern) { if (!hostMatch) { errorLogger.log(new Error("Could not construct URL: request host " + sourceHost + " should match " + sourceBaseUrlPattern)); - return replaceDomain(targetBaseUrlPattern || sourceBaseUrlPattern, "c9.io"); + return replaceDomain(targetBaseUrlPattern || sourceBaseUrlPattern, "c9.io") + .replace(/\/$/, ""); } - return replaceDomain(targetBaseUrlPattern || sourceBaseUrlPattern, hostMatch[1]); + return replaceDomain(targetBaseUrlPattern || sourceBaseUrlPattern, hostMatch[1]) + .replace(/\/$/, "");; }; plugin.replaceDomains = function(settings, domains) {