kopia lustrzana https://github.com/c9/core
Make profile multi-domain aware
rodzic
23f3e6e809
commit
9eeccd6d05
|
@ -30,7 +30,7 @@ function main(options, imports, register) {
|
||||||
* @param {String} [targetBaseUrlPattern] The target URL pattern, e.g. https://$DOMAIN
|
* @param {String} [targetBaseUrlPattern] The target URL pattern, e.g. https://$DOMAIN
|
||||||
*/
|
*/
|
||||||
plugin.getBaseUrl = function(req, sourceBaseUrlPattern, targetBaseUrlPattern) {
|
plugin.getBaseUrl = function(req, sourceBaseUrlPattern, targetBaseUrlPattern) {
|
||||||
var sourceHost = req.host || req;
|
var sourceHost = req.headers && req.headers.host || req.host || req;
|
||||||
var sourceHostMatcher = sourceBaseUrlPattern
|
var sourceHostMatcher = sourceBaseUrlPattern
|
||||||
.replace(/^https?:\/\//, "")
|
.replace(/^https?:\/\//, "")
|
||||||
.replace(/\/.*/, "")
|
.replace(/\/.*/, "")
|
||||||
|
@ -39,10 +39,12 @@ plugin.getBaseUrl = function(req, sourceBaseUrlPattern, targetBaseUrlPattern) {
|
||||||
if (!hostMatch) {
|
if (!hostMatch) {
|
||||||
errorLogger.log(new Error("Could not construct URL: request host "
|
errorLogger.log(new Error("Could not construct URL: request host "
|
||||||
+ sourceHost + " should match " + sourceBaseUrlPattern));
|
+ 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) {
|
plugin.replaceDomains = function(settings, domains) {
|
||||||
|
|
Ładowanie…
Reference in New Issue