Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging
This commit is contained in:
commit
43589d10b6
13
server.js
13
server.js
@ -169,16 +169,18 @@ if (config.privKeyAndCertFiles) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
app.get('/api/config', function(req, res){
|
var admins = [];
|
||||||
var host = req.headers.host.replace(/\:[0-9]+/, '');
|
try {
|
||||||
var admins = [];
|
|
||||||
try {
|
|
||||||
admins = (config.adminKeys || []).map(function (k) {
|
admins = (config.adminKeys || []).map(function (k) {
|
||||||
k = k.replace(/\/+$/, '');
|
k = k.replace(/\/+$/, '');
|
||||||
var s = k.split('/');
|
var s = k.split('/');
|
||||||
return s[s.length-1].replace(/-/g, '/');
|
return s[s.length-1].replace(/-/g, '/');
|
||||||
});
|
});
|
||||||
} catch (e) { console.error("Can't parse admin keys"); }
|
} catch (e) { console.error("Can't parse admin keys"); }
|
||||||
|
|
||||||
|
app.get('/api/config', function(req, res){
|
||||||
|
// TODO precompute any data that isn't dynamic to save some CPU time
|
||||||
|
var host = req.headers.host.replace(/\:[0-9]+/, '');
|
||||||
res.setHeader('Content-Type', 'text/javascript');
|
res.setHeader('Content-Type', 'text/javascript');
|
||||||
res.send('define(function(){\n' + [
|
res.send('define(function(){\n' + [
|
||||||
'var obj = ' + JSON.stringify({
|
'var obj = ' + JSON.stringify({
|
||||||
@ -192,6 +194,7 @@ app.get('/api/config', function(req, res){
|
|||||||
websocketURL:'ws' + ((useSecureWebsockets) ? 's' : '') + '://' + host + ':' +
|
websocketURL:'ws' + ((useSecureWebsockets) ? 's' : '') + '://' + host + ':' +
|
||||||
websocketPort + '/cryptpad_websocket',
|
websocketPort + '/cryptpad_websocket',
|
||||||
httpUnsafeOrigin: config.httpUnsafeOrigin,
|
httpUnsafeOrigin: config.httpUnsafeOrigin,
|
||||||
|
adminEmail: config.adminEmail,
|
||||||
adminKeys: admins,
|
adminKeys: admins,
|
||||||
}, null, '\t'),
|
}, null, '\t'),
|
||||||
'obj.httpSafeOrigin = ' + (function () {
|
'obj.httpSafeOrigin = ' + (function () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user