mailtrain/lib/urls.js
Tomas Bures 7788b0bc67 Fixed sandbox. Multiple tabs work now.
WiP on selectable mosaico templates.

TODO: Make files always point to trusted URL, such that we don't have to rebase them. They are public anyway. The same goes for mosaico endpoints: /mosaico/templates and /mosaico/img
2018-05-09 04:07:01 +02:00

43 lines
No EOL
1.1 KiB
JavaScript

'use strict';
const config = require('config');
const urllib = require('url');
function getTrustedUrlBase() {
return urllib.resolve(config.www.trustedUrlBase, '');
}
function getSandboxUrlBase() {
return urllib.resolve(config.www.sandboxUrlBase, '');
}
function getTrustedUrl(path) {
return urllib.resolve(config.www.trustedUrlBase, path || '');
}
function getSandboxUrl(path, context) {
if (context && context.user && context.user.restrictedAccessToken) {
return urllib.resolve(config.www.sandboxUrlBase, context.user.restrictedAccessToken + '/' + (path || ''));
} else {
return urllib.resolve(config.www.sandboxUrlBase, 'ANONYMOUS/' + (path || ''));
}
}
function getTrustedUrlBaseDir() {
const ivisUrl = urllib.parse(config.www.trustedUrlBase);
return ivisUrl.pathname;
}
function getSandboxUrlBaseDir() {
const ivisUrl = urllib.parse(config.www.sandboxUrlBase);
return ivisUrl.pathname;
}
module.exports = {
getTrustedUrl,
getSandboxUrl,
getTrustedUrlBase,
getSandboxUrlBase,
getTrustedUrlBaseDir,
getSandboxUrlBaseDir
};