The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Rocket.Chat/packages/rocketchat-lib/lib/getURL.js

21 lines
601 B

import { Meteor } from 'meteor/meteor';
import s from 'underscore.string';
RocketChat.getURL = (path, { cdn = true, full = false } = {}) => {
const cdnPrefix = s.rtrim(s.trim(RocketChat.settings.get('CDN_PREFIX') || ''), '/');
const pathPrefix = s.rtrim(s.trim(__meteor_runtime_config__.ROOT_URL_PATH_PREFIX || ''), '/');
let basePath;
const finalPath = s.ltrim(s.trim(path), '/');
if (cdn && cdnPrefix !== '') {
basePath = cdnPrefix + pathPrefix;
} else if (full) {
return Meteor.absoluteUrl(finalPath);
} else {
basePath = pathPrefix;
}
return `${ basePath }/${ finalPath }`;
};