kopia lustrzana https://github.com/c9/core
Revert "Put user content on a different domain"
rodzic
bee22480da
commit
043984c8e1
|
@ -1,9 +0,0 @@
|
|||
/*
|
||||
* Swap keys and values of an object
|
||||
*/
|
||||
exports.invert = function(obj) {
|
||||
return Object.keys(obj).reduce(function(res, key) {
|
||||
res[obj[key]] = key;
|
||||
return res;
|
||||
}, {});
|
||||
};
|
|
@ -43,14 +43,5 @@ exports.repeat = function(str, times) {
|
|||
exports.count = function(str, substr){
|
||||
return str.split(substr).length - 1;
|
||||
};
|
||||
|
||||
exports.endsWith = function(subjectString, searchString, position) {
|
||||
if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
|
||||
position = subjectString.length;
|
||||
}
|
||||
position -= searchString.length;
|
||||
var lastIndex = subjectString.indexOf(searchString, position);
|
||||
return lastIndex !== -1 && lastIndex === position;
|
||||
};
|
||||
|
||||
});
|
|
@ -22,14 +22,6 @@ 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.
|
||||
*
|
||||
|
@ -38,8 +30,10 @@ plugin.getHost = function(req) {
|
|||
* @param {String} targetBaseUrlPattern The target URL pattern, e.g. https://$DOMAIN
|
||||
*/
|
||||
plugin.getBaseUrl = function(req, sourceBaseUrlPattern, targetBaseUrlPattern) {
|
||||
var sourceHost = plugin.getHost(req);
|
||||
|
||||
var sourceHost = req.headers && req.headers.host
|
||||
|| req.host
|
||||
|| req.url && req.url.replace(/^https?:\/\/([^/]*).*/, "$1")
|
||||
|| req;
|
||||
if (typeof sourceHost !== "string")
|
||||
throw new Error("Not a valid request object: " + req);
|
||||
if (!sourceBaseUrlPattern)
|
||||
|
|
|
@ -39,13 +39,7 @@ define(function(require, exports, module) {
|
|||
session.ws = {};
|
||||
|
||||
req.projectSession = session.ws[ws];
|
||||
|
||||
if (
|
||||
!req.projectSession ||
|
||||
!req.projectSession.expires ||
|
||||
req.projectSession.expires <= Date.now() ||
|
||||
req.projectSession.uid != req.user.id
|
||||
) {
|
||||
if (!req.projectSession || !req.projectSession.expires || req.projectSession.expires <= Date.now()) {
|
||||
req.projectSession = session.ws[ws] = {
|
||||
expires: Date.now() + 10000
|
||||
};
|
||||
|
@ -83,7 +77,6 @@ define(function(require, exports, module) {
|
|||
}
|
||||
req.projectSession.role = role;
|
||||
req.projectSession.pid = project.id;
|
||||
req.projectSession.uid = req.user.id;
|
||||
|
||||
var type = project.scm;
|
||||
req.projectSession.type = type;
|
||||
|
@ -144,8 +137,8 @@ define(function(require, exports, module) {
|
|||
|
||||
var path = req.params.path;
|
||||
var url = req.proxyUrl + path;
|
||||
if (req.user.code)
|
||||
url += "?access_token=" + encodeURIComponent(req.user.code);
|
||||
if (req.session.token)
|
||||
url += "?access_token=" + encodeURIComponent(req.session.token.id || req.session.token);
|
||||
|
||||
var parsedUrl = parseUrl(url);
|
||||
var httpModule = parsedUrl.protocol == "https:" ? https : http;
|
||||
|
|
10
server.js
10
server.js
|
@ -23,12 +23,14 @@ var DEFAULT_CONFIG = "s";
|
|||
var DEFAULT_SETTINGS = getDefaultSettings();
|
||||
|
||||
var shortcuts = {
|
||||
"dev" : ["ide", "preview", "user-content", "vfs", "api", "sapi", "proxy", "redis", "profile", "oldclient", "homepage", "apps-proxy", "-s", "devel"],
|
||||
"odev" : ["ide", "preview", "user-content", "vfs", "api", "proxy", "oldclient", "homepage", "apps-proxy", "profile", "worker", "-s", "onlinedev"],
|
||||
"beta" : ["ide", "preview", "user-content", "vfs", "proxy", "-s", "beta"],
|
||||
"dev" : ["ide", "preview", "vfs", "api", "sapi", "proxy", "redis", "profile", "oldclient", "homepage", "apps-proxy", "-s", "devel"],
|
||||
"odev" : ["ide", "preview", "vfs", "api", "proxy", "oldclient", "homepage", "apps-proxy", "profile", "worker", "-s", "onlinedev"],
|
||||
"bill" : ["ide", "preview", "vfs", "api", "proxy", "oldclient", "homepage", "apps-proxy", "profile", "-s", "billing"],
|
||||
"beta" : ["ide", "preview", "vfs", "proxy", "-s", "beta"],
|
||||
"ci" : ["ide", "preview", "vfs", "proxy", "-s", "ci"],
|
||||
"s" : ["standalone", "-s", "standalone"]
|
||||
};
|
||||
var delayLoadConfigs = ["preview", "user-content", "api", "oldclient", "apps-proxy", "worker"];
|
||||
var delayLoadConfigs = ["preview", "api", "oldclient", "apps-proxy", "worker"];
|
||||
|
||||
module.exports = main;
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue