diff --git a/node_modules/c9/urls.js b/node_modules/c9/urls.js index a1b000af..8f5fc472 100644 --- a/node_modules/c9/urls.js +++ b/node_modules/c9/urls.js @@ -22,6 +22,14 @@ function main(options, imports, register) { }); } +plugin.getHost = function(req) { + return (req.headers && req.headers.host + || req.host + || req.url && req.url.replace(/^https?:\/\/([^/]*).*/, "$1") + || req + ); +}; + /** * Get a desired base URL, given some context. * @@ -30,10 +38,8 @@ 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.headers && req.headers.host - || req.host - || req.url && req.url.replace(/^https?:\/\/([^/]*).*/, "$1") - || req; + var sourceHost = plugin.getHost(req); + if (typeof sourceHost !== "string") throw new Error("Not a valid request object: " + req); if (!sourceBaseUrlPattern)