|
|
|
@ -3,13 +3,13 @@ import s from 'underscore.string'; |
|
|
|
|
import { isURL } from './isURL'; |
|
|
|
|
import { settings } from '../../settings'; |
|
|
|
|
|
|
|
|
|
function getCloudUrl(path, _site_url) { |
|
|
|
|
function getCloudUrl(path, _site_url, cloudRoute) { |
|
|
|
|
const siteUrl = s.rtrim(_site_url, '/'); |
|
|
|
|
|
|
|
|
|
// Remove the protocol
|
|
|
|
|
const host = siteUrl.replace(/https?\:\/\//i, ''); |
|
|
|
|
path = s.ltrim(path, '/'); |
|
|
|
|
const url = `https://go.rocket.chat/?host=${ encodeURIComponent(host) }&path=${ encodeURIComponent(path) }`; |
|
|
|
|
const url = `https://go.rocket.chat/${ cloudRoute }?host=${ encodeURIComponent(host) }&path=${ encodeURIComponent(path) }`; |
|
|
|
|
|
|
|
|
|
if (siteUrl.includes('http://')) { |
|
|
|
|
return `${ url }&secure=no`; |
|
|
|
@ -18,7 +18,7 @@ function getCloudUrl(path, _site_url) { |
|
|
|
|
return url; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const _getURL = (path, { cdn, full, cloud, _cdn_prefix, _root_url_path_prefix, _site_url }) => { |
|
|
|
|
export const _getURL = (path, { cdn, full, cloud, cloud_route, _cdn_prefix, _root_url_path_prefix, _site_url }) => { |
|
|
|
|
if (isURL(path)) { |
|
|
|
|
return path; |
|
|
|
|
} |
|
|
|
@ -28,6 +28,7 @@ export const _getURL = (path, { cdn, full, cloud, _cdn_prefix, _root_url_path_pr |
|
|
|
|
const query = _query ? `?${ _query }` : ''; |
|
|
|
|
|
|
|
|
|
const siteUrl = s.rtrim(s.trim(_site_url || ''), '/'); |
|
|
|
|
const cloudRoute = s.trim(cloud_route || ''); |
|
|
|
|
const cdnPrefix = s.rtrim(s.trim(_cdn_prefix || ''), '/'); |
|
|
|
|
const pathPrefix = s.rtrim(s.trim(_root_url_path_prefix || ''), '/'); |
|
|
|
|
|
|
|
|
@ -44,16 +45,17 @@ export const _getURL = (path, { cdn, full, cloud, _cdn_prefix, _root_url_path_pr |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (cloud) { |
|
|
|
|
return getCloudUrl(url, siteUrl); |
|
|
|
|
return getCloudUrl(url, siteUrl, cloudRoute); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return url; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export const getURL = (path, { cdn = true, full = false, cloud = false } = {}) => _getURL(path, { |
|
|
|
|
export const getURL = (path, { cdn = true, full = false, cloud = false, cloud_route = '' } = {}) => _getURL(path, { |
|
|
|
|
cdn, |
|
|
|
|
full, |
|
|
|
|
cloud, |
|
|
|
|
cloud_route, |
|
|
|
|
_cdn_prefix: settings.get('CDN_PREFIX'), |
|
|
|
|
_root_url_path_prefix: __meteor_runtime_config__.ROOT_URL_PATH_PREFIX, |
|
|
|
|
_site_url: settings.get('Site_Url'), |
|
|
|
|