kopia lustrzana https://github.com/c9/core
add user content moved page
rodzic
88c9baaf62
commit
8224fb8c66
|
@ -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.
|
* 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
|
* @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.headers && req.headers.host
|
var sourceHost = plugin.getHost(req);
|
||||||
|| req.host
|
|
||||||
|| req.url && req.url.replace(/^https?:\/\/([^/]*).*/, "$1")
|
|
||||||
|| req;
|
|
||||||
if (typeof sourceHost !== "string")
|
if (typeof sourceHost !== "string")
|
||||||
throw new Error("Not a valid request object: " + req);
|
throw new Error("Not a valid request object: " + req);
|
||||||
if (!sourceBaseUrlPattern)
|
if (!sourceBaseUrlPattern)
|
||||||
|
|
Ładowanie…
Reference in New Issue