Add multi-domain support to most of the sign-in flow

pull/117/merge
Lennart kats 2015-06-29 13:58:14 +00:00
rodzic aaeceb921f
commit e252cb3a18
1 zmienionych plików z 12 dodań i 7 usunięć

19
node_modules/c9/urls.js wygenerowano vendored
Wyświetl plik

@ -26,8 +26,8 @@ function main(options, imports, register) {
* Get a desired base URL, given some context.
*
* @param req The current request object or URL
* @param {String} sourceUrlPattern The source URL pattern, e.g. https://ide.$DOMAIN
* @param {String} [targetBaseUrlPattern] The target URL pattern, e.g. https://$DOMAIN
* @param {String} [sourceUrlPattern] The source URL pattern, e.g. https://ide.$DOMAIN
* @param {String} targetBaseUrlPattern The target URL pattern, e.g. https://$DOMAIN
*/
plugin.getBaseUrl = function(req, sourceBaseUrlPattern, targetBaseUrlPattern) {
var sourceHost = req.headers && req.headers.host
@ -39,15 +39,20 @@ plugin.getBaseUrl = function(req, sourceBaseUrlPattern, targetBaseUrlPattern) {
.replace(/\/.*/, "")
.replace("$DOMAIN", "([^/]+)");
var hostMatch = sourceHost.match(sourceHostMatcher);
if (!hostMatch) {
var targetHost;
if (hostMatch) {
targetHost = hostMatch[1];
}
else {
errorLogger.log(new Error("Could not construct URL: request host "
+ sourceHost + " should match " + sourceBaseUrlPattern));
return replaceDomain(targetBaseUrlPattern || sourceBaseUrlPattern, "c9.io")
.replace(/\/$/, "");
targetHost = "c9.io";
}
return replaceDomain(targetBaseUrlPattern || sourceBaseUrlPattern, hostMatch[1])
.replace(/\/$/, "");;
if (targetHost.match(/^(ide|vfs)./) && !targetBaseUrlPattern)
errorLogger.log(new Error("Warning: no targetBaseUrlPattern specified, will stay at " + targetHost), { sourceBaseUrlPattern: sourceBaseUrlPattern });
return replaceDomain(targetBaseUrlPattern || sourceBaseUrlPattern, targetHost)
.replace(/\/$/, "");
};
plugin.replaceDomains = function(settings, domains) {