kopia lustrzana https://github.com/c9/core
Add multi-domain support to most of the sign-in flow
rodzic
aaeceb921f
commit
e252cb3a18
|
@ -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) {
|
||||
|
|
Ładowanie…
Reference in New Issue