Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.getBaseURL = function (/*optional*/req) {
if (!req) {
req = exports.currentRequest();
}
if ('baseURL' in settings) {
return settings.baseURL;
}
if (exports.isBrowser()) {
var baseURL = cookies.readBrowserCookie('baseURL');
if (baseURL) return baseURL;
var re = new RegExp('(.*\\/_rewrite).*$');
var match = re.exec(exports.getWindowLocation().pathname);
if (match) {
return match[1];
}
return '';
}
if (req.query.baseURL) {
return req.query.baseURL;
}
if (req.query.db && req.query.ddoc) {
return '/' + req.query.db + '/_design/' + req.query.ddoc + '/_rewrite/';
}
exports.readBrowserCookie = function () {
var cookie = cookies.readBrowserCookie('_duality_flash');
var messages = cookie ? JSON.parse(unescape(cookie)): [];
return _.map(messages, function (val) {
val.incoming = true;
val.outgoing = false;
return val;
});
};